I am struggling to learn python, but I need several scripts to make the games I’m planning on. I don’t know how much of this stuf is possible in python, but here goes.
I need scripts for:
1-breaking parents in-game ( shooting limbs off, w00t)
2-making a static object dynamic in-game (could be combined with #1, so the limbs that are shot off move dynamically)
3-modifying a variable (i.e. health) of an object it collides with (e.g. a bullet lowering the health of just that which it hits- I want to do it this way because of the sheer number of weapon types I plan on having)
4-getting the velocity of an object (e.g. so a falling rock can do damage according to how fast it’s moving, when combined with #3)
If anybody has any scripts i could use/suggestions for a better way to do something/place i could learn some more pyhton (I’ve gone through several documentations and tutorials, I’m not sure which ones though, I might be able to pick apart a script I’m given, but I’m helpless when it comes to creating them) I would be very pleased.
2 - You can use “suspendDynamics()” and “restoreDynamics()”.
3 - This one you can do without python. Just use the message sensors and actuators.
4 - “getLinearVelocity()”, will return a list of three velocity variables [x,y,z]. So if you wanted to get an objects falling velocity, you would do “getLinearVelocity()[2]” (Z axis). All you need to do now is employ a controll statement to handle the exerted damage based on that velocity. ( I assume you know how to setup a controll loop statement to initiate an action, and increment variables. If you don’t, go to the python site and learn that first.)
If I may suggest a good way to learn things:
Start with something more basic, like a clone of your favorite classic game. I don’t know what game your trying to make currently, but it sounds like your starting off a little too complicated, considering that you are not very familiar with the game engine.
correct me if I’m wrong, but if I wanted a bullet to just do damage to the object it hit, with the message actuator, I’d have to have a message actuator for every object in the game that could take damage from that bullet, attached to a collision sensor for each object. this seems a little excessive to me. Also, it would effect every instance of an object that got added while the game was running, right? or could I use python to put only the name of the object the bullet hit into the “to:” field of the message actuator.
thanks for the rest of the info though. Right now I’m just making little tests, not really games, that can be used later in games.
correct me if I’m wrong, but if I wanted a bullet to just do damage to the object it hit, with the message actuator, I’d have to have a message actuator for every object in the game that could take damage from that bullet
Yes, it would be much easier to use a python script for the bullet. They weren’t showing collisions for a bit on added objects but I’m pretty sure that’s been fixed in the latest release.
I’m leaving out imports, testing for positive on the sensor, and making sure the object has a health property, etc. You could also put a damage property on the types of bullets and use the same script for every type of bullet.
hey thanks for the get velocity info etc… I was wanting to make objects smash when they get hit at certain velocity and then have fragments which again only break when hit above a certain velocity… like the fracture system in havoc…
I was thinking you wanted to have score displayed for each shot, in which case you would either have to use the message sensor to send an increment variable signal to your scoreboard, or have a scoreboard script access the shot objects properties. If you just want for the objects to keep track of collision, and “health”, you do not need the message sensors/actuators.
Sorry if I confused you, scoreboards are always on my mind it seems, lol.