Hello!
I’m creating a game with a friend.
In the game we want the characters to slide down slopes, so we created a OnControllerColliderHit function in order to print out the dot product between the hit.normal and the gravity vector (to get the slide direction).
On his computer the dot products prints all fine everytime he moves from one surface to another, but on my computer it updates only while the object is on the edge of a surface. Meaning: when I start it prints 0 (flat surface) then updates once I get onto a new surface (e.g 0.50), if I then go back to the original flat surface, the print value does not update to 0.
The project is simply moved from his computer to mine. Why doesen’t it update?
function OnControllerColliderHit(hit : ControllerColliderHit)
{
print(1-Vector3.Dot(hit.normal,Vector3.Normalize(Vector3(0,6,0))));
}
Vector3(0,6,0) is simply the gravity vector.
It wont update if I put it inside the Update() function and do this, either:
var down : Vector3 = transform.TransformDirection(Vector3.down);
var rayposLeft : Vector3 = new Vector3(transform.position.x,transform.position.y,transform.position.z);
if (Physics.Raycast(rayposLeft,down,hit,0.8f)){
print(hit.normal);
}
Thanks in advance!