ssatguru / BabylonJS-CharacterController

A CharacterController for BabylonJS
Apache License 2.0
216 stars 46 forks source link

Bug with lesson animation + jump #8

Closed dad72 closed 4 years ago

dad72 commented 4 years ago

Hi,

When you walk while jumping, it works, but if you run, you can't jump at the same time.

Thanks

dad72 commented 4 years ago

I just understood by testing your Demo that only the jump animation works while running.

My model has no animation on the jump. But it jumps anyway when we walk (at least it is move on the Y axis) But not when we run.

It was just to clarify.

ssatguru commented 4 years ago

Hi @dad72 , With version 2.0 I added 2 jumps "idleJump" and "runJump" . "idleJump" plays when avatar is idle. "runJump" plays while walking, running etc. Instead of "runJump" maybe I should have called it just "jump" :( Thanks

dad72 commented 4 years ago

My runJum doesn't work. I do not know why ? I'm not talking about the animations, but about moving along the Y axis. When I run, I can't jump.

ssatguru commented 4 years ago

Can you provide a test/demo?

dad72 commented 4 years ago

No I have no online tests currently, my project is local

ssatguru commented 4 years ago

Jump should work during walking and running. In the demo it works. Until i see your code I can't say why it does not work for you.

dad72 commented 4 years ago

Ok, I made you a test file online.

1) The jump bug from what I understand, this product as soon as: cc.setWalkKey("Z"); If I change the keyboard key, the jump no longer works (if I leave by default with W it works. In this online demo the key is Z

2) You can also see that the character is facing me now and even if I put: cc.setFaceForward(false); cc.setMode(0); The character still faces me. No changes. It worked well before yesterday's update

3) Try to run into space, then release the keys on the keyboard. You can see that the character continues to run through the void until it hits the ground. I would like a change of animation when it jumps into the void (a dive for example like a parachute jump) There the animation remains blocked on : walk or run.

4) Gravity also doesn't seem to be high enough. Logically a gravity is around 9.81. There I putting 98.1 so that gravity is more coherent. It's huge, but correct. If I put 9.8, the character takes a long time to hit the ground

I hope this helps you see better.

Online: http://www.babylon.actifgames.com/characterController/index.html Zip: http://www.babylon.actifgames.com/characterController/tst.zip

Thank you for this CharacterController

ssatguru commented 4 years ago

Thanks for the test file. It helped me catch some nasty bugs :)

1) The keys have to be in specified in caps. "W" not "w", "Z" not "z" 2) fixed cc.setFaceForward(false) and cc.setMode(0) 3) fixed. the character would now play the "fall" animation 4) 9.81 is probably low for games but physics correct. As people can easily change this ,I would leave it as is for now. Attached is your test file with the new charactercontroller. tst.zip

dad72 commented 4 years ago
  1. I did use capital letters for letters in the demo (cc.setWalkKey("Z");). I must have explained it wrong. If by default (W) the jump works in running. But if I change it with Z (use capital letters). it no longer works the jump in running. Try it on the demo. Comment the line 79: setWalkKey ('Z') The jump will be good. Uncomment, the jump will no longer run while running.

  2. Fixe, yes

  3. I still have the same problem. I may have expressed myself badly again. Put yourself on top of the mountain at the highest. Run towards the edge. When you are in a vacuum, release the keyboard, the Run animation continues until the character hits the ground. If we want the character to jump by parachute or others, the character runs in the void.

  4. I understand for this one, it is not a major problem.

  5. I discovered another bug following the update. Try to "strafe Left" (Q). Then "Run" (Z). Are both animation playing at the same time?

  6. Do you plan to update the Readme to reflect the changes?

The online demo has been updated with your changes.

ssatguru commented 4 years ago
  1. I do not know why it isn't working for you :( . I tried your online demo. It works for me. (Also walk is "Z" , run is "Shift" + "Z")

  2. On line 95 use cc.setFallAnim to set the fall animation. If fall animation is not set it will continue to play the runJump animation and if runJump animation is not set it will continue to play the Run animation until the avatar hits the ground.

5.If "strafeLeft/strafeRight" and "Run/Walk/WalkBack" are pressed together then just "Run/Walk/WalkBack" will play. Only "turnLeft/turnRight" and "Run/Walk/WalkBack" (SHIFT+W/W/S and A/D) will play together.

6.Yes. I plan to publish to NPM this weekend and will update the Readme.

Thanks for testing this out,

dad72 commented 4 years ago

Ok, for 2). Fixed.

For 1). Yes at my place, no running jump. It works if you leave the default 'W' key for the same demo I sent you. Are we talking about the same thing? If you press space, you can see the character take off from the ground? Same thing when you walk. But when we run, nothing, the character 'Run', but do not 'Jump' if I change the key to W by default. I also don't understand why this is happening.

For 5). Do you have trouble understanding what I'm writing? I use a translator to write in English, so you may not understand the translation well. If I click on Q to slide to the right (I'm not talking about turning right), then after I run, the character runs, but also trembles while trying to slide to the right. Which is not normal. There is actually a bug here that didn't happen before.

It is quite discreet . You have to run the character quickly to see it. It also seems random.

dad72 commented 4 years ago

I tried another keyboard key using 'R' to walk and run. The strange thing is that it works to also jump while running. Only with the redefined 'Z' key which prevents the jump in current. Yes, it’s strange, I don’t explain it. Ideas ? What does it have my Z key (It works however because my character walks and runs)

dad72 commented 4 years ago

Ok, I'm starting to understand. I find what is wrong I think.

To make it work, I press Z then SHIFT then SPACE and release SHIFT to get the jump. If I click on SPACE last it will not work, I must then release SHIFT to get the jump.

Is this normal? If I have more than 3 keys using Z, the jump does not work.

I also change this in your code: ( in _onKeyDown(e) and _onKeyUp(e) )

e = e || window.event; const code = e.which || e.keyCode; const chr = String.fromCharCode(code);

I also add the TAB key to lock the run and the runing and jump character.

dad72 commented 4 years ago

I close this problem which is partly solved.