- Home /
Create new rays, based on forward but rotated
I'm creating an A* pathfinding algorithm and I'm trying to draw 4 rays in all directions:
- One which will be pointing forward 
- One to the back 
- One to the left 
- One to the right 

To draw the forward ray, I simple used:
     forwardRay.origin = transform.position;
     forwardRay.direction = transform.forward;
Works perfectly, but how do I add a side ray? It must be added to the forwardray, but I'm stuck with what kind of rotation method I have to add.
 
                 
                unityanswer.png 
                (8.6 kB) 
               
 
              
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by robertbu · Dec 26, 2013 at 08:40 PM
You can do this:
 backRay.origin = transform.position;
 backRay.direction = -transform.forward;
 
 rightRay.origin = transform.position;
 rightRay.direction = transform.right;
 
 leftRay.origin = transform.position;
 leftRay.direction = -transform.right;
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                