Bouncing Damaging Projectiles
by Chris Byars · in Torque Game Engine · 06/26/2005 (2:41 pm) · 8 replies
What I need is a projectile that is bouncy when it hits things, but also causes damage when it collides with a player.
Currently I am using the armingDelay to allow the projectile to be bouncy as it skips along the terrain/interiors/players, but it does not cause direct damage to an object. (Obviously because it's "arming" is delayed to allow it to bounce before exploding and disappearing.)
So somehow I need it so the projectile object causes damage if the player is hit by it without the projectile "exploding", allowing it to bounce around until its lifetime is up.
Currently I am using the armingDelay to allow the projectile to be bouncy as it skips along the terrain/interiors/players, but it does not cause direct damage to an object. (Obviously because it's "arming" is delayed to allow it to bounce before exploding and disappearing.)
So somehow I need it so the projectile object causes damage if the player is hit by it without the projectile "exploding", allowing it to bounce around until its lifetime is up.
#2
06/26/2005 (3:55 pm)
What I'm doing is simulating throwing things you pick up using projectiles, and need it so they act somewhat like that.
#3
06/27/2005 (12:49 pm)
Actually I realized what I need is projectiles to do direct damage, without exploding. I set the lifetime less than the armingDelay so the projectiles don't explode at all, rather fade away when their lifetime is up. But I need the projectile that is shot to damage a player if it collides with them.
#4
Your question triggered a solution to another problem I was working on, so thanks!
To attempt to answer your question though, you could simply apply damage to the player in the projectiles OnCollision() function, as the object being collided with is supplied to you. To apply damage, simply call %obj.Damage(), which can be found (and modified) in player.cs in starter.fps. Everything's in script.
If you need more fine-grained control, take a peek in ProcessTick() in projectile.cc.
06/27/2005 (11:27 pm)
Chris,Your question triggered a solution to another problem I was working on, so thanks!
To attempt to answer your question though, you could simply apply damage to the player in the projectiles OnCollision() function, as the object being collided with is supplied to you. To apply damage, simply call %obj.Damage(), which can be found (and modified) in player.cs in starter.fps. Everything's in script.
If you need more fine-grained control, take a peek in ProcessTick() in projectile.cc.
#5
this is what I used in Toons.. the projectile will bounce as long as you specify and will not explode until either max life time is reached or it hits a player.. I also included the vehicle class so it explodes on contact with them also...
have fun.. :)
06/28/2005 (4:01 am)
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5954this is what I used in Toons.. the projectile will bounce as long as you specify and will not explode until either max life time is reached or it hits a player.. I also included the vehicle class so it explodes on contact with them also...
have fun.. :)
#6
@Tom Feni: I'll probably use that resource, although I was planning on having the projectile to bounce off the player as well as apply damage, not to explode on impact with the player, but that will probably do.
06/28/2005 (5:21 am)
@Eugene: I don't see the OnCollision() function, only:function gunProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
// Apply damage to the object all shape base objects
if (%col.getType() & $TypeMasks::ShapeBaseObjectType)
%col.damage(%obj,%pos,%this.directDamage,"gunBullet");
}@Tom Feni: I'll probably use that resource, although I was planning on having the projectile to bounce off the player as well as apply damage, not to explode on impact with the player, but that will probably do.
#7
Edit:
That is the OnCollision(); function that you've pasted code from. It's seperate for each object, as you wouldn't want all of them to behave in the same way.
06/28/2005 (5:35 am)
Then just don't remove the projectile when it collides, throw a raycast based on where it hit and recreate the projectile based on the vector given from the raycast(or redirect the already existing one) to make it look like it's bouncing.Edit:
Quote:
@Eugene: I don't see the OnCollision() function, only:
That is the OnCollision(); function that you've pasted code from. It's seperate for each object, as you wouldn't want all of them to behave in the same way.
#8
noBounceObjTypes = $TypeMasks::PlayerObjectType;
Says to not bounce off players so you could just not have that or have different ObjectTypes.
And in the OnCollision for your weapons projectile you could apply damage to the player.
06/28/2005 (5:38 am)
@c2 Using the resource Tom Feni used.noBounceObjTypes = $TypeMasks::PlayerObjectType;
Says to not bounce off players so you could just not have that or have different ObjectTypes.
And in the OnCollision for your weapons projectile you could apply damage to the player.
Torque Owner Stefan Lundmark