So I've been looking up numerous differently worded sentences to find the answer to this topic, and I just can't seem to find anything.
Long story short, I want to find if the camera is on the terrain. I'm using the collision tutorial code.
Trying to make a jump where the camera goes up a distance before falling down, but you can only jump if something is directly underneath of you.
To answer any questions, I did do a setPosition for the camera, but I'm doing this for an uneven terrain, so if you were on top of a hill, you could jump then wait until you stop going up to jump again (like you're flying).
Any help is appreciated. Thanks in advance.
-Luna
C++ - Check if camera is touching the terrain (Collision)
-
- Posts: 386
- Joined: Sun May 11, 2014 12:13 am
Re: C++ - Check if camera is touching the terrain (Collision
I don't use the terrain scenenode yet. But I think you can get the height by feed it X, Z position.
For camera affect under gravity using simple motion law ignoring air friction.
V^2 = U^2 + 2a(Ds)
V = u + at
S = So + ut + 1/2at^2
Just apply the formula to find Y direction at anytime when jump, then compare with the terrain Y position to prevent go through. Assume jump velocity u is known.
Regards
Thanh
For camera affect under gravity using simple motion law ignoring air friction.
V^2 = U^2 + 2a(Ds)
V = u + at
S = So + ut + 1/2at^2
Just apply the formula to find Y direction at anytime when jump, then compare with the terrain Y position to prevent go through. Assume jump velocity u is known.
Regards
Thanh
-
- Posts: 386
- Joined: Sun May 11, 2014 12:13 am
Re: C++ - Check if camera is touching the terrain (Collision
I don't understand your method.
I can find your current position at jump, then increase the Y to a certain Y above where you jumped. However, if you happen to be jumping and reach that max, I have no way of detecting if you've hit the ground or not. So you can jump again.
If I make the jump delay so they can't jump after so long, of you jump off a mountain you'll be able to jump in air again.
I need some way to find true or false if you are on the ground or not.
I can find your current position at jump, then increase the Y to a certain Y above where you jumped. However, if you happen to be jumping and reach that max, I have no way of detecting if you've hit the ground or not. So you can jump again.
If I make the jump delay so they can't jump after so long, of you jump off a mountain you'll be able to jump in air again.
I need some way to find true or false if you are on the ground or not.
Re: C++ - Check if camera is touching the terrain (Collision
If using a terrain scene ode there is a getheight(x,a) function you can check against your character pos.y
-
- Posts: 386
- Joined: Sun May 11, 2014 12:13 am
Re: C++ - Check if camera is touching the terrain (Collision
Thank you, I'll look into it. Does this method go for the overall height? Or the height of the vertex below your camera??