Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow jumping only when entity stands on something #98

Closed
Doidel opened this issue Jun 22, 2013 · 9 comments
Closed

Allow jumping only when entity stands on something #98

Doidel opened this issue Jun 22, 2013 · 9 comments

Comments

@Doidel
Copy link

Doidel commented Jun 22, 2013

Hi

My player is able to jump. Yet I want him to only be able to jump if he stands on something, so he doesn't jump in mid-air.
I thought about using collision detection, but if the player just walks over a cliff there's no "noticing" that he's mid-air. Another thought was to use

object._physijs.touches

I could iterate through all touched objects, figure out the contact normal (how? no clue) and like this determine whether he's standing on something or not.

Does someone have a good idea on how to do this? Any suggestions would definitely be appreciated!

Kind regards,
Doidel

@chandlerprall
Copy link
Owner

Contact normal would need to be added to the collisions report. That's an important part of responding to collisions and should be added.

@Doidel
Copy link
Author

Doidel commented Jun 24, 2013

heh, I agree ^^
how about looping through the "touches" how I mentioned before. You know anything that speaks against this..?

@chandlerprall
Copy link
Owner

That's how I would do it. Depending on your set up you may be able to fake the contact normal by checking if the player is above the platform or not.

@Doidel
Copy link
Author

Doidel commented Jun 25, 2013

Right, I'll give it a shot. Faking it won't be possible, the level's too complex for that (too many objects).
Thanks for the help!

@Doidel
Copy link
Author

Doidel commented Jun 28, 2013

Hmm touches won't really work, I need that contact normal... if I e.g. have a terrain I can barely figure out whether the player stands upon it or is in the air. Can you drop a message here when you added that contact normal? That'd be neat.. thanks in advance :)

@Doidel
Copy link
Author

Doidel commented Jul 14, 2013

Is that contact normal available by now..?

@chandlerprall
Copy link
Owner

Can't believe it's already been 3 weeks... I'll get this pushed out tonight.

@Doidel
Copy link
Author

Doidel commented Jul 15, 2013

Awesome, thanks!

@chandlerprall
Copy link
Owner

Wiki Collisions page updated with the new contact_normal parameter in the collision callback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants