Collision detection for jumping

I need a tutorial or maybe some pointers, here is my code

Hi @genre,

What problem does your code has? Are you getting any errors?

If you do a forum search you will get plenty of similar topics and some provide solutions and sample code for jumping. Give it a try, here is an example project:


@Leonidas I can jump but i need detection so i can’t jump infinitely, so like when i jump once it detects when i hit the floor and has a little cool down cause i don’t know how to use ray cast on Chromebook

Hi @genre

You need to detect collision for that (check this project: PlayCanvas 3D HTML5 Game Engine )

You can copy the collision script from there into your main script, just need to add one bool variable, when you detect collision from an object, change the state.
Just make sure to check from which object you are getting collision, make sure to use tags, if not, you would be able to jump near walls or any object which is not ground.

1 Like

do i add the script in the update area?

No, please take a look at the example project on how collision detection works.
You can copy the "onCollisionStart " function at the end of your script, just change the name of the script pointer, so instead “Collider” replace with yours.
Copy event line from initialize function, to yours.
Make sure you check the tag of the object u collide with, if its ground then change your state this.jumping.state to true.

put it at the end like this?
Screenshot 2021-10-23 7.11.38 PM

sorry if this irritating im new to coding still.