Test walking character bullet position

I’m trying to change a copy of Test walking character to automatic weapons fire…the weapons fire seems to work well the issue is now that the bullet doesn’t fire from the position of the firing arm anymore and vary with the direction of the camera even colliding with the character sometimes, the rate of fire I use now is very slow for testing and the problem persists…



In the default semi auto way this was made, I can quickly fire off several shoots(faster than auto rate) and not get this issue…what am I doing wrong



I created a shoot boolean and created a shoot update call

[java]if(shoot && (double)(timer.getTimeInSeconds() - lastFire) > 0.20000000000000001D){

lastFire = timer.getTimeInSeconds();

bulletControl();



}[/java]



and this is the shoot action

[java]else if (binding.equals(“CharShoot”)){

if(value){

shoot=true;

}

else {

shoot=false;

}[/java]



other than that, I changed the bullet to fire in the camera’s direction (which showed no issues in the original semi auto fire mode so I am doubting that’s the issue :?

anybody, I’ve tried a few things but can’t quite figure out simple changing the fire behavior is causing issues.

The bullet collides with the character.

ok I found the issue I didn’t change [java](modelDirection.mult(1.8f)[/java] to sync with the fact that the bullet now use the cam direction…my bad sry :roll:

one other question, what would be the best i.e. safest way to kill bullets that would not have collided with the scene I notice if I fir into “space” over an extended period the frame rate drops considerably and will continue to drop until its unplayable

Not using physics bodys for bullets but using rayTests. Otherwise keeping a list and checking it in intervals.

Hello! I have been working on Jmonkey a very short while so I am a little confused–it’s summer school–no choice but to dive in!

I am attempting the same thing and was wondering if I could get a little clarification. I have searched the tests and tutorials on something with automatic fire to no avail-- could you please help me out on the logic?



So in the WalkingCharacterTest:

I have added

[java]if(shoot && (double)(timer.getTimeInSeconds() - lastFire) > 0.20000000000000001D){

lastFire = timer.getTimeInSeconds();

bulletControl();

} [/java]

to the simpleUpdate method



and added



[java]else if (binding.equals(“CharShoot”)) {

if(value){

shoot = true;

}

else {

shoot = false;

}[/java]

to the onAction method as originally suggested.



but now the character won’t respond to a spacebar key press…and I am also confused as to where the camera gets changed…I’m assuming it’s in bulletControl where the local translation is set? but I am not sure…

I also read a forum post where the rapid fire was done like this…



[java]if (name.equals(“Shoot”)) {

accumulatedShot += tpf;

int shotCount = accumulatedShot / rateOfFire; // Rate of fire float seconds count

if (shotCount > 0 || lastShotTime < System.currentTimeMillis()-rateOfFire*1000) {

shoot(max(shotCount, 1));

accumulatedShot -= shotCount * rateOfFire;

}

}[/java]



but I can’t seem to wrap my brain around what is the correct way to go about this…if there’s a tutorial out there that I missed I would really appreciate a step in the right direction!



thanks!!