And another...
I have a physics body as the ground, with the player standing on it. How do I detect whether the player is touching the ground, to determine whether he can jump? Or is there a better way?
(At the moment, the player can keep jumping whilst in the air, as if they're flapping wings and flying upwards...)
[Edit] I've kind of hacked a solution to this, by checking the Y position of the player when they press the jump key, and not making him jump if he's too high. It seems quite crap though - is it more standard to do some kind of collision check between the player and the ground, and base it off that?
My ongoing newbie questions
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: My ongoing newbie questions
There are going to be callbacks not only when collision starts, but also when it stops, allowing you to use a simple ground boolean, in the mean time:
You can check if 1 pixel below the lowest point is in the ground, in that case, you're on the ground. (use testPoint on the shape)
You can check if 1 pixel below the lowest point is in the ground, in that case, you're on the ground. (use testPoint on the shape)
Re: My ongoing newbie questions
Yeah, I've done something similar, cheers.
Q. How do I detect a collision between a bullet and an enemy?
Q. How do I detect a collision between a bullet and an enemy?
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: My ongoing newbie questions
Create the bullet as a physics entity and just fire it, you do need to set identification data and register a collision callback, but the docs of love.physics should help you with that. So basically it's the same as when you were firing other objects. ![Razz :P](./images/smilies/ms-razz.png)
![Razz :P](./images/smilies/ms-razz.png)
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], DTmg, Google [Bot] and 2 guests