Simple Enemy/Manipulatable Objects
by Marvin Hawkins · in Torque Game Engine · 11/28/2008 (10:40 pm) · 3 replies
Hey Everyone,
Hopefully everyone's 11/27 was enjoyable. Or Thanksgiving stateside.
I spent some time on that day wrestling with a problem: I have arrows that bounce. I want to create a script so that when my projectiles collide with an object. (I was testing on the ammo/health patch datablocks) They "react."
I was trying to do a simple scale (since I understand that the best out of any torquescript calls now) on the objects that were being shot.
when I got to the HealthData::oncollision.
I added obj.scale before the functions that allowed the player to "pick up" this object.
but nothing happened.
I know this is because I don't have a firm grasp on collision events in torque. ( I did notice that Torque is not a very conditional heavy structure.) So two questions. 1) How/where do I handle what an object does when something collides with it?
Also I know the player can collide with this object (healthkit, helathpatch) but can the projectiledata datablock. If not, how can I set up collisions between objects from different sources.
I apologize if any of this is unclear.
Hopefully everyone's 11/27 was enjoyable. Or Thanksgiving stateside.
I spent some time on that day wrestling with a problem: I have arrows that bounce. I want to create a script so that when my projectiles collide with an object. (I was testing on the ammo/health patch datablocks) They "react."
I was trying to do a simple scale (since I understand that the best out of any torquescript calls now) on the objects that were being shot.
when I got to the HealthData::oncollision.
I added obj.scale before the functions that allowed the player to "pick up" this object.
but nothing happened.
I know this is because I don't have a firm grasp on collision events in torque. ( I did notice that Torque is not a very conditional heavy structure.) So two questions. 1) How/where do I handle what an object does when something collides with it?
Also I know the player can collide with this object (healthkit, helathpatch) but can the projectiledata datablock. If not, how can I set up collisions between objects from different sources.
I apologize if any of this is unclear.
#2
I just refference it as an Itemobject type?
What do you mean by using an object? I'm sorry if that's a noobish question. But do you mean creating a new object from the ItemObject Datablock?
11/30/2008 (3:02 pm)
Hmm I think i see the logic behind it. Insgtead of refferencing a typemask as a ShapeBaseobject type. (Does this line check to see if the the "orc player object has collided with an arrow?")I just refference it as an Itemobject type?
What do you mean by using an object? I'm sorry if that's a noobish question. But do you mean creating a new object from the ItemObject Datablock?
#3
Where is the DirectDamage Function?
11/30/2008 (5:02 pm)
Hmmm im not sure why but that this doesn't work. Where is the DirectDamage Function?
Torque Owner Mike Rowley
Mike Rowley
If you look in crossbow.cs, around line 764 in the crossbows onCollision method, you can add a check for the object being an item, then do your scale from there.
// Apply damage to the object all shape base objects if (%col.getType() & $TypeMasks::ShapeBaseObjectType) %col.damage(%obj,%pos,%this.directDamage,"CrossbowBolt");add after...something along the lines of this untested code....
// Apply damage to the object all Item objects if (%col.getType() & $TypeMasks::ItemObjectType) %col.damage(%obj,%pos,%this.directDamage,"CrossbowBolt");I don't know if that code is entirely correct, or if it will work. It's an example of where you would want to make your changes. You would also want to change the directDamage block to resize the item. (or avoid all this by using an object)