Game Development Community

What does this code mean and do?

by Dustin Mullen · in Technical Issues · 05/05/2008 (4:11 pm) · 2 replies

I found this in the starter.racing-server-scripts- car.cs I'm assuming that I can setup the car to take damage when it runs into a projectile or a projectile hits the car (considering I setup the car to shoot projectiles such as the death car for example).

So, how do I get this to work for the deathcar (it shoots arrows)?



}



function WheeledVehicleData::onCollision(%this,%obj,%col,%vec,%speed)

{

// Collision with other objects, including items

}

#1
05/05/2008 (11:25 pm)
Assuming the onCollision method works(i dont understand if that was your question), you could compare the %obj(car)'s mass with %col(the collision item)'s mass. If Its postive, deal damage to car, if negative, deal damage to col. Then scale the damage with the speed.

Alternaly, you could use the speed obj is traveling, multiply this by its mass, and then find the dot product between car and obj and multiply with this. I think that would result in dealing more damage the more dead on you were hiting the other car, compared to the cars EyeNode or whatever marks its front. This would be kind of silly though, since that would mean that you would deal most damage to other cars if you hit them in the front, and hardly any at all, if you hit them in the rear.
#2
05/07/2008 (2:22 pm)
Yea, i'm not sure if the onCollision method works with the racing kit.

I setup the code like this:

If %obj(car) %col(crossbow)
Damage=1


That's probably totally wrong, but it's been awhile since I've worked with torque, so inform me of what i am doing wrong.