Game Development Community

Vehicle Death and Respawning

by Jon · in Technical Issues · 09/20/2004 (4:31 pm) · 8 replies

Ok... I've been working on vehicle based game. The problem I'm having is when the vehicle dies. I can get the vehicle out of the mission along with the mounted player but when the vehicle respawns I can no longer take damage, pickup items, or anything else besides drive around. I created my own getState() function since I kept on getting error saying that it couldn't find the function. I made my own variable for the state and also my own variable called damageLevel that allows me to check it and determine what state the car should be in, Alive or Dead. Well I set the car's state to Dead when the damageLevel >= maxDamage and when I respawn and re-create the vehicle in the game.cs file I set the state back to Alive and the damageLevel back to 0. I can post the code if anyone wants to look at it but I was just wondering if anyone can give me a rundown on all the processes that happen when respawning a vehicle and have it take damage again.

I'm guessing that since i'm using my own getState() and not the engines that I'm having issues with what state the vehicle is in. Maybe the engine still thinks that the car is dead but my scripts says its alive. I test the state variable to after the car is re-created in the game.cs and it says "Alive" but when I shoot the car it still tells me its "Dead". Any thoughts?

If you need more info just let me know and I will gladly give it.

#1
09/20/2004 (7:50 pm)
Ok... getting somewhere, when I respawn for some reason I am keeping the same values as the previous spawn. I did an echo(myObj.state); and its telling me it's dead and echo(myObj.damageLevel); and its tell me its 100 (both echos from the console). When I print an echo message from the game.cs file of the respawning cars state it tells me its alive with a damageLevel of 0. So some reason or another the new settings are not taking effect. I'll try to add a cleanup function after I schedule the deletion of the player and vehicle and see what happens.
#2
09/20/2004 (11:07 pm)
Ok... found the problem.... I fixed it by doing, in the game.cs file %car.dataBlock.state = "Alive"; & %car.dataBlock.damageLevel = 0;
thanks to all (me) for helping out! ..... just kidding this is the best community on the net along with the Linux/GNU community! .... of course.... :)

Now time for damageEmitters and a nice explosion for the finale!
#3
09/20/2004 (11:15 pm)
Hehe...
#4
09/22/2004 (4:34 pm)
Ok I got a prob, I can spawn the car...easy, I can see the car and walk up to it...no prob. But for some reason I cant mount my player to it. Its there and looks great, but the player just sits there an doesnt do anything no matter what button I press. What am I missing here? Any suggestions?
#5
09/22/2004 (5:39 pm)
I'm guessing that you are walking up to the car to mount it and not pressing a button. Have you checked your mount node? make sure your node is equal to the node you want to mount to, this is located in the player.cs in the onMount function which should be called from the onCollision function. Also make sure you have set your car's mountable attribute to true in your
datablock WheeledVehicleData(DefaultCar)
{
...
...
mountable = true;
}

Hope this helps
#6
09/22/2004 (6:34 pm)
Lol, well I checked on that and found that I was doing it wrong, when I got that fixed I can now mount the car, no prob and drive it, however Now I cant dismount from the car. Whats ur thoughts on this. Ive looked around and it looks as though I should easily be able to dismount, however whenever I try, my player just stands up and waves his gun and then locks into the car. U can still drive the car, but the only way to get out of the car is to commit suicide.
#7
09/23/2004 (10:33 pm)
Do you have an doDismount function in your player.cs ?
#8
09/23/2004 (11:44 pm)
Well I really screwed it up trying to fix it. The thing is, for some reason even though it is scripted to use a key to mount and dismount, it was mounting me automatically just by the player touching it. I tried to fix it, however, somewhere I messed up, adn now I cant even mount. I think I know what I did by making the player have 1 in inventory or by setting the player as always mounted already. This is getting confusing.