rotating a direction

Hi,

I’m tryng to rotate a direction of a gameobject, by 20 degrees.
This is what i’m doing :

var bla : Vector3;
transform.Rotate(20,0,0);
bla = -transform.forward*30;
transform.Rotate(-20,0,0);
Debug.DrawRay(transform.position,bla,Color.green);

While this should work, i think the process i’m using to rotate the direction vector is quite, how to say…, inneficient.
Is there a more efficient way to do this ?
What i’m tryng to do, is find a few directions, this is for AI behaviour, so i’m not tryng to actually rotate the object, just the direction he “looks”.

thanks for any advice,

Bruno

mhmm,

As for I see that code shouldn’t compile, as the transform.Rotate function receives either a vector3, or various numbers, and you are passing it a single number…

that way of doing the things I don’t see it inefficient (the transform.Rotate), what you can do is creating a Rotation and applying it directly to the transform. but I don’t think it will affect the efficiency…

you right, the transform.Rotate would not compile, that was a typo on my part.
Fixed it :stuck_out_tongue:
I was just wondering if there’s a more ellegant way of doing this, this code works, that’s not the point :wink:

thanks,
Bruno

I dont think its inefficient :slight_smile: