Simulating FPS damage and hitbox

I’m attempting to create damage using the collision event where my bullets explode. I’m using the Oto model and physics character node from the TestWalkingChar java except that I extended PhysicsCharacterNode into a MyCharacter class with damage, health, etc all just with basic get and set functions.

The issue is that if I hit the character in the chest it registers the giveDamage(25) function 6 times. If I hit him along the “arm” or perhaps jsut the edge of the collision capsule, it only registers 1. How can I get a consistent 1 time damage registering?



Code

[java]public void collision(PhysicsCollisionEvent event) {

if (“bullet”.equals(event.getNodeA().getName())) {

final Node nodeA = event.getNodeA();

final Node nodeB = event.getNodeB();

enqueue(new Callable() {



public Object call() throws Exception {

getPhysicsSpace().remove(nodeA);

nodeA.removeFromParent();

effect.killAllParticles();

effect.setLocalTranslation(nodeA.getLocalTranslation());

effect.emitAllParticles();



return null;

}

});

if (“character”.equals(nodeB.getName()) || “model”.equals(nodeB.getName())) {

System.out.println(“dmging character”);

character.giveDamage(25);

}

} else if (“bullet”.equals(event.getNodeB().getName())) {

final Node nodeA = event.getNodeA();

final Node nodeB = event.getNodeB();

enqueue(new Callable() {



public Object call() throws Exception {

getPhysicsSpace().remove(nodeB);

nodeB.removeFromParent();

effect.killAllParticles();

effect.setLocalTranslation(nodeB.getLocalTranslation());

effect.emitAllParticles();



return null;

}

});

if (“character”.equals(nodeA.getName()) || “model”.equals(nodeA.getName())) {

System.out.println(“dmging character”);

character.giveDamage(25);

}

}

}[/java]

Store the time of the last impact and react only if enough time has passed for example?

I’ve been wondering that because I’m unfamiliar with how to grab the timer or some variable of time passed, that would be really useful to know for everything I’m doing.

set in the update a field

boolean hitthistick = false;



(Just choose a update that runs after the physicupdates, maybee you need to create a own one, not sure)

I think the rest is simple (if not ask again)

@EmpirePhoenix that seemed to work so far, thanks much for the tip.

You can just accumulate the tpf’s you get to count the time.

normen said:
You can just accumulate the tpf's you get to count the time.


I've never heard an explanation of the tpf number though. "time per frame" I assume. But does that translate to the ms within a frame? out of some max that I set?

How would I implement it?

Its a float value containing the time since the last frame in 1/1000s The explosion test uses the tpf in the way mentioned.

Are frames objective or are they different dependent on clientside or fps? cause I intend on implementing this to multiplayer and if I do would simply making sure the server handles this check be sufficient to make sure it’s consistent to all players?

The time per frame is of course dependent on the frames per second, yes. I dont know what you are doing exactly, google about the different ways to synchronize objects over the network (client based, server based etc.). In a simple networking version the clients could simply report their damage (which of course is prone to hacks on the client side if you ever expect anybody to hack your software).

I’m learning and attempting to implement a server based multiplayer game, not an MMO (at this point maybe when I’ve learned a LOT more). I’m using physics right now but they don’t seem necessary (it was simply the easiest way to get a familiar control feel to it). I’m currently working with a 3rd person view, interface, graphics, and controls similar to a EQ or WoW type of MMO. Except not auto attacking, a simple left click = fire method of attack. Would you mind checking out a basic layout (common english) of what i think my server-client needs to do?