Hi,
My Program test if my Character is in front of a slope >60 degree. It works but I want only upward Slope !! not downward slope.
So I wonder how to know when my Character climb and not go down.
thanks
A+
How to know if my Character go up or go down a slope ?
-
- Posts: 24
- Joined: Tue Sep 22, 2015 1:34 pm
-
- Posts: 463
- Joined: Fri Nov 30, 2012 4:50 am
Re: How to know if my Character go up or go down a slope ?
If you already know the slope why not just calculate the current position vs the slope normal? Assuming X axis is forward from the facing direction to the slope, a positive rotation in the y means up slope and negative means downslope. The entire implementation would require only a few matrix multiplications at most, and very simple to figure out, if a bit unoptimized.
-
- Posts: 24
- Joined: Tue Sep 22, 2015 1:34 pm
Re: How to know if my Character go up or go down a slope ?
I tried
But it doesn't seem to work.
Code: Select all
Ogre::Quaternion q = Ogre::Vector3(point.m_positionWorldOnA).getRotationTo(Ogre::Vector3(point.m_normalWorldOnB));
float rotation =q.y ;
-
- Posts: 24
- Joined: Tue Sep 22, 2015 1:34 pm
Re: How to know if my Character go up or go down a slope ?
please, anyone ?
-
- Posts: 96
- Joined: Wed Mar 16, 2016 10:11 am
Re: How to know if my Character go up or go down a slope ?
If it doesn't work, is m_positionWorldOnA and m_normalWorldOnB correct?
If the problem is really come from quaternion, more information about quaternion can be found in ...
http://gamedev.stackexchange.com/questi ... quaternion
Look at the first answer and all its links. It is the best one I found so far.
If the problem is really come from quaternion, more information about quaternion can be found in ...
http://gamedev.stackexchange.com/questi ... quaternion
Look at the first answer and all its links. It is the best one I found so far.
-
- Posts: 24
- Joined: Tue Sep 22, 2015 1:34 pm
Re: How to know if my Character go up or go down a slope ?
I found a solution.
Code: Select all
Ogre::Vector3 dir = PJ->mNode->getOrientation() * Vector3::UNIT_Z;
Ogre::Radian q = Ogre::Vector3(dir).angleBetween(Ogre::Vector3(point.m_normalWorldOnB));
Ogre::Real rotation =q.valueDegrees()-90 ;