I don’t actually know how to see the forums of my own questions… (so please email me at:
siloaman@hotmail.ca)
My question is really simple.
I have an Avatar that moves across a floor panel maybe 20x20.
I am able to use Debug.DrawRay to watch his Local Forward Direction using:
straightForward = transform.TransformDirection(Vector3.forward) * 10;
What I need to do is create a second DrawRay function that will look in front of him angled towards the ground like he’s watching where he is going.
At the start of the game run, my code was:
- straightForward = transform.TransformDirection(Vector3.forward) * 10; (Vector3)
- noAngle = straightForward; (Vector3)
- spreadAngleDown = Quaternion.AngleAxis(15, new Vector3(1,0,0)); (Quaternion)
- newVectorDown = noAngle * spreadAngleDown; (Vector3)
if (Physics.Raycast(transform.position, newVectorDown, 10))
{
Debug.DrawRay(transform.position, newVectorDown, Color.green);
Debug.DrawRay(transform.position, straightForward, Color.cyan);
//Debug.Log(“Looking at something :)”);
onPlatform = true;
}
This code would essentially say that if the Avatar can see something in front of him… feel free to move ahead. However, when I coded in Input.GetKey(Space) assume its correct and I (transform.Rotate(0, 90, 0, Space.Self) the Avatar to his right side… I ran the same 1-4 steps coding again…
Problem is: my DrawRay that looks directly forward is working, but the angled down DrawRay gets wacky, looking upwards and nowhere and random places… I think it’s because its multiplying the Quaternion angles by a new set of world axis values, not Avatar local values… can someone please help me so that my angled DrawRay always looks at the ground in front of my Avatar local direction???
Please send extra copy of answer to: siloaman@hotmail.ca