How would one create stats for a weapon i know it’d have to be by using python, but i can’t find a script can someone please provide a example if it’s to complicated perhaps just only damage, also how would i get a ray sensor to interact with a dynamic object?
Sorry new to blednerartist.com also thanks in advance it will truly be a great help to me in creating my game
‘Stats’ Is that a visual representation of it, or it’s actual damage values?
Right, let’s have a look at this the Object Oriented approach.
What inflicts the damage. The bullet.
So which object should know how much damage to incflict? The bullet!
So create a property on the bullet called… ‘Damage’ and give it a value (say, 10)
What knows how much health you have left? The player.
So where should the health value be stored? The player!
So create a property on the player called … ‘Health’ and give it a value (say, 100)
Then you create a script that detects what objects have collided with it, and subtracting them. I can write one for you if you like.
Of course, that requires there to be real physical objects as bullets, that fly around. This works for slow things like explosions and missiles (or slow lasers) but is pretty weird for real bullets.
If you use raycasts (ie hitscan weapons) then it is a lot more complex. I’m sure monster can explain it better than me, so I’ll leave it for him.
You actually don’t need any python at all, though it certainly helps from an organisational standpoint. You also don’t need to use ray casts.
Make the weapon’s collision mesh a rigid object( it can be ghost), and make the object it collides with static, rigid, or dynamic( probably soft will work too). They can both be ghosts if you want.
Then using logic bricks. Set the weapon collision mesh with a property say “hit” and the target object to have a collision sensor that detects property “hit.”
If you’re still having problems I can upload a blend example.
sdfgeoff’s advice is great for explaining object oriented. It’s pretty much the same thing I’m saying.
sdfgeoff, I’d really like to see that script. I was going to use messages to get the weapon properties across, but I’d like to see what you come up with.
@noctambulant666 - You shouldn’t use soft body meshes for collisions - they’re very physics intensive. The colliding mesh could probably be a dynamic object rather than a rigid body one, as collisions matter, not how they react.