Page 1 of 1

How to get position of a projectile?

Posted: Sat May 09, 2020 12:44 am
by Kiplacon
I have a stream projectile (like spitter acid and flamethrower fire), and when I call for its location with ProjectileName.position it gives me the location where the projectile spawned, no matter where the flying projectile currently is in its arc. Is there a way to get the position of the projectile itself?

Re: How to get position of a projectile?

Posted: Sat May 09, 2020 6:33 am
by PyroFire
How are you getting the projectile to begin with?
There's no on_weapon_fired event.

Also what are you trying to do?

Re: How to get position of a projectile?

Posted: Sat May 09, 2020 4:58 pm
by Kiplacon
I give the projectile a name when I spawn it like:
global.rock = create_entity ({projectile details})

Then in a different script I want to repeatedly teleport the player to that projectile to simulate motion like:
if (global.rock.valid) then
game.get_player(1).teleport(global.rock.position)
end

But when I run this, it just repeatedly teleports the player to the location where the projectile was spawned instead of to the projectile itself, so the player gets stuck there until the projectile finishes its course.

Re: How to get position of a projectile?

Posted: Sat May 09, 2020 9:47 pm
by Klonan
Kiplacon wrote: Sat May 09, 2020 4:58 pm I give the projectile a name when I spawn it like:
global.rock = create_entity ({projectile details})

Then in a different script I want to repeatedly teleport the player to that projectile to simulate motion like:
if (global.rock.valid) then
game.get_player(1).teleport(global.rock.position)
end

But when I run this, it just repeatedly teleports the player to the location where the projectile was spawned instead of to the projectile itself, so the player gets stuck there until the projectile finishes its course.
Streams don't have a 'projectile', that is a visual only thing.

You probably want to just calculate the tranjectory on your own:
https://en.wikipedia.org/wiki/Projectile_motion