How to get position of a projectile?
How to get position of a projectile?
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?
How are you getting the projectile to begin with?
There's no on_weapon_fired event.
Also what are you trying to do?
There's no on_weapon_fired event.
Also what are you trying to do?
Re: How to get position of a projectile?
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.
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?
Streams don't have a 'projectile', that is a visual only thing.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.
You probably want to just calculate the tranjectory on your own:
https://en.wikipedia.org/wiki/Projectile_motion