# Find angle between two Y positions...?

This topic is 4925 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Didn't work... :/

Now the vehicle is more or less locked to the ground....
This is the code I'm currently using:
        GroundLevel = GetAltitude(Pos.x,Pos.z);        Direction += GravityVector;        vector3d OldPos = Pos;        Pos += Direction*g_delta;        if (Pos.y < GroundLevel+Radius)        {        float angle2 = atan2(sqrt((OldPos.x*OldPos.x)+(OldPos.z*OldPos.z)),OldPos.y);        float angle1 = atan2(sqrt((Pos.x*Pos.x)+(Pos.z*Pos.z)),Pos.y);        TerrainElevation = angle2-angle1;//        TerrainElevation = 50; //should be AngleOf(OldPos.y,Pos.y);        Direction.SetDirection(VehicleYaw,TerrainElevation,CurrentSpeed);        Pos.y = GroundLevel+Radius;        }

##### Share on other sites
I'll look at your code more carefully in a bit, but meanwhile, are you missing any radian/degree conversions?

##### Share on other sites
Ah, I think you're trying to solve a different problem than I thought. Try this:

Vector3 v = pos - oldPos;
pitch = atan2(v.y,sqrt(v.x*v.x+v.z*v.z)); // You might have to negate this

I think pitch is what you're calling 'TerrainElevation'.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 10
• 23
• 13
• 10
• 9
• ### Forum Statistics

• Total Topics
634476
• Total Posts
3017705
×