Data Realms Fan Forums
http://45.55.195.193/

Projectile detection?
http://45.55.195.193/viewtopic.php?f=1&t=15265
Page 1 of 1

Author:  Kyred [ Tue Jun 09, 2009 2:37 am ]
Post subject:  Projectile detection?

Is there anyway, through lua script, to check to see if there is a non-actor object, like a projectile (MOPixel, MOSRotating/AEmitter), near a position?

I'm trying to write a script for barrier that stops projectiles in mid-air. When a projectile enters the barrier's spherical field, its velocity begins to decrease until it reaches zero (or in this case, a zero vector). At first, I tried using SceneMan:CastMORay()'s to search around the barrier's center, doing a ray cast every pi/12 radians up to 2pi. Through testing, I found this method worked for actors but not projectiles.

So is there a way to know whether or not a projectile has entered the barrier's field?

Author:  Grif [ Tue Jun 09, 2009 2:43 am ]
Post subject:  Re: Projectile detection?

for particle in MovableMan.Particles

if particle.Pos

That's how you iterate through the list, though it's going to be laggy.

Author:  Duh102 [ Tue Jun 09, 2009 2:43 am ]
Post subject:  Re: Projectile detection?

Ninja'd by Grif again.

You can reduce the lag somewhat by using a rectangular search area, but it won't look too nice if you make a square field.

Author:  Kyred [ Tue Jun 09, 2009 3:09 am ]
Post subject:  Re: Projectile detection?

Thanks Grif.

It seems MovableMan has a lot of child variables that arn't documented. What other MovableMan.<something>'s are there that don't appear in the Lua docs?

Author:  Grif [ Tue Jun 09, 2009 3:12 am ]
Post subject:  Re: Projectile detection?

MovableMan.Particles, Actors, and Devices should be everything. I think.

Author:  Geti [ Tue Jun 09, 2009 3:15 am ]
Post subject:  Re: Projectile detection?

i think its MovableMan.Items actually..
for easy near-ness detection you can use
Code:
(self.Pos - particle.Pos).Magnitude < radius
, which is better and faster than square boxes.

Author:  Kyred [ Tue Jun 09, 2009 4:19 am ]
Post subject:  Re: Projectile detection?

Woo! Got it working =D.

Author:  zalo [ Tue Jun 09, 2009 5:15 am ]
Post subject:  Re: Projectile detection?

It's funny that you had thought of that.

I'd thought of it some time in May, but left it because it was kind of laggy.

You can have it if you want to look at it as an example.

Attachments:
File comment: My Version.
PinClone.rte(2).rar [15.49 KiB]
Downloaded 150 times

Author:  Kyred [ Tue Jun 09, 2009 9:39 pm ]
Post subject:  Re: Projectile detection?

To cut down on lag, I delayed the for loop in the update to every 10ms with a timer, and reset the timer every time the if statement has passed. Worked pretty well. Also, you'll want to exclude any particles with the preset name "None".

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/