Projectile position/velocity (reading or changing)
by Eric Lavigne · in Torque Game Engine · 12/19/2004 (7:17 pm) · 6 replies
I am trying to make projectiles do some nonstandard stuff, but I can't find a way to control a projectile after it starts moving.
projectile::position
Gives me the position of the projectile, but it seems to be read-only. Any changes I make to this variable are temporary and have no visible effect on the projectile.
projectile::velocity
Does not exist. The closest thing I found to this was initialvelocity. I was very surprised by this. Are there scriptors who care more about knowing initial velocity than about knowing/changing current velocity?
So, in summary, I know the position but can't change it. I don't know the velocity and can't change it.
Even if I weren't trying to control the projectiles, the ability to check a projectile's velocity seems valuable for other things, such as creating an AI that dodges missiles. Surely there's a way to at least determine (and maybe change) this information by script?
Any ideas about how to change a projectile's motion after it has been fired would be appreciated.
projectile::position
Gives me the position of the projectile, but it seems to be read-only. Any changes I make to this variable are temporary and have no visible effect on the projectile.
projectile::velocity
Does not exist. The closest thing I found to this was initialvelocity. I was very surprised by this. Are there scriptors who care more about knowing initial velocity than about knowing/changing current velocity?
So, in summary, I know the position but can't change it. I don't know the velocity and can't change it.
Even if I weren't trying to control the projectiles, the ability to check a projectile's velocity seems valuable for other things, such as creating an AI that dodges missiles. Surely there's a way to at least determine (and maybe change) this information by script?
Any ideas about how to change a projectile's motion after it has been fired would be appreciated.
About the author
#2
Private forums are only for things that involve c++.
12/19/2004 (7:55 pm)
If it can be done with script, then this is the place to post. Do you know how to do it with script?Private forums are only for things that involve c++.
#3
If we wanted a projectile to change directions, we would spawn a new projectile at max velocity and delete the old one. This basicaly allows you to fake it, just make sure to transfer parameters need from old to new each time you do this.
The only other way is with engine modifications.
12/19/2004 (9:30 pm)
As so far as I remember you cannot alter the projectiles properties once it is created. The script hack arounds we used was as follows.If we wanted a projectile to change directions, we would spawn a new projectile at max velocity and delete the old one. This basicaly allows you to fake it, just make sure to transfer parameters need from old to new each time you do this.
The only other way is with engine modifications.
#4
12/22/2004 (5:02 am)
I like your hack, Ralph. I decided to make my first engine mod instead though. It's a resource (still unapproved) called Terrain Following Missiles. I can't link to it here, since this is the public forum, but the "Guided or Seaker Projectiles" resource in the patches section has a link to it.
#5
Object 'NormalMissile' is not a member of the 'GameBaseData' datablock class.
HOWEVER... if I wait a moment after my projectile (NormalMissile) has been destroyed, I can then create another one with not problems or errors.
What gives? I know you can chain-gun projectile's, so why isn't it let me create more than one at a time?
01/19/2005 (3:30 pm)
I took a go at this hack you suggested, however it refused to let me create a second instance of the ProjectileData datablock because it gives the error:Object 'NormalMissile' is not a member of the 'GameBaseData' datablock class.
HOWEVER... if I wait a moment after my projectile (NormalMissile) has been destroyed, I can then create another one with not problems or errors.
What gives? I know you can chain-gun projectile's, so why isn't it let me create more than one at a time?
#6
01/19/2005 (3:39 pm)
Dave, since you're an SDK owner, you can just use my resource instead of reinventing it. It's called terrain following missiles, and it's number 3 in code snipits right now. I can't paste a link, though, because this is a public forum and it involves TGE source code. With my resource, I can easily fill the screen with my terrain following missiles, and it's quite pretty :)
Torque Owner Josh Moore