- Home /
rotation with eulerangles and raycasting.
I have an object that moves around and when it meets the wall it gives me a boolean for the wall, which in turn allows the object to turn around. the issue is that the raycasting to enable the booleans do not rotate with the gameobject... to rotate the object when the boolean is true I use eulerAngles. is there a better way to rotate the object? without losing the orientation of the raycasting?
as an example for the raycast:
var fwall0:RaycastHit; //wall in front of the object.
var forRay = new Ray(transform.position, Vector3.forward);
if(Physics.Raycast(forRay, fwall0)){
if(fwall0.distance < walldist){
fwall=true;
}
if(fwall0.distance > walldist){
fwall=false;
}
}
Answer by robertbu · Aug 13, 2013 at 03:10 PM
You want to use transform.forward not Vector3.forward:
var forRay = new Ray(transform.position, transform.forward);
Your answer
Follow this Question
Related Questions
Look At Player with Clamping. 1 Answer
Why is this rotation not performed as expected? 1 Answer
When applying a 90 degree rotation to Euler Angles, it is over/undershooting sometimes.. 2 Answers
How to limit rotation of an object when pressing a key? 2 Answers
Is there a fix for ground normals rotates my player in unwanted ways? 0 Answers