- Home /
Rotate FPS Char from Standard Asset
Is there anyone know how to rotate The FPS Char from standard asset. Somehow i want to rotate it at Start function, but it didn't work, thank you
Answer by Azzure_Light · Jul 16, 2017 at 12:18 PM
Thanks again WideEyeNow, so my code:
gameObject.transform.localEulerAngles = new Vector3(0, Random.Range(0, 360), 0);
(i use array to specify some angle and random it) and your code:
Vector3 randomRotation = new Vector3(0, Random.Range(0, 360), 0);
transform.Rotate(randomRotation);
are actually working. I find out that my mistake is I put it on the FPS Controller script. (Shouldn't it has to be working too?). So I create new script with the code, attach to the FPS char and it's working now. Thanks again WideEyeNow for the reply. Really appreciate that.
Best way to thank me is to at least UpVote my answer :) That'll give me a little bit of rep, which I could use. But good, it's working for ya. I see you meant rotate on the Y-axis, sorry I thought you meant rotate left and right.
Answer by WideEyeNow · Jul 14, 2017 at 12:35 PM
This may be a tad buggy? Not sure haven't tested it, but this would go in Start() or Awake(). And basically tells the transform, or the gameObject that has this code:
if Vector3 == 1,0,-1 rotate southeast I think?
Vector3 randomRotation = new Vector3(Random.Range(-1,1), 0, Random.Range(-1,1));
transform.Rotate (randomRotation);
You might have to play with it a little bit :)
Thanks for the reply, i mean that everytime the game start i want to rotate the fps char in random specified angle. I think we have to override the 2 scripts attached on the fps char, but still didn't know how.