View unanswered posts | View active topics It is currently Wed Jan 08, 2025 5:08 pm



Reply to topic  [ 9 posts ] 
 Projectile detection? 
Author Message
User avatar

Joined: Sun May 31, 2009 1:04 am
Posts: 308
Reply with quote
Post 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?


Tue Jun 09, 2009 2:37 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post 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.


Tue Jun 09, 2009 2:43 am
Profile
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post 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.


Tue Jun 09, 2009 2:43 am
Profile
User avatar

Joined: Sun May 31, 2009 1:04 am
Posts: 308
Reply with quote
Post 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?


Tue Jun 09, 2009 3:09 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Projectile detection?
MovableMan.Particles, Actors, and Devices should be everything. I think.


Tue Jun 09, 2009 3:12 am
Profile
User avatar

Joined: Sun Jul 13, 2008 9:57 am
Posts: 4886
Location: some compy
Reply with quote
Post 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.


Last edited by Geti on Tue Jun 09, 2009 9:51 pm, edited 1 time in total.



Tue Jun 09, 2009 3:15 am
Profile WWW
User avatar

Joined: Sun May 31, 2009 1:04 am
Posts: 308
Reply with quote
Post Re: Projectile detection?
Woo! Got it working =D.


Tue Jun 09, 2009 4:19 am
Profile

Joined: Sat Feb 03, 2007 7:11 pm
Posts: 1496
Reply with quote
Post 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
Tue Jun 09, 2009 5:15 am
Profile WWW
User avatar

Joined: Sun May 31, 2009 1:04 am
Posts: 308
Reply with quote
Post 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".


Tue Jun 09, 2009 9:39 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 9 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.031s | 16 Queries | GZIP : Off ]