Question by
Dog-Gamer · May 10, 2016 at 12:01 AM ·
javascriptprogramming
How to stop model form rotating back to face down?
In my game the enemy is standing straight up after i rotate him here. Then once he follows the script or may i say tun on the game he gos back to his original face down position.
Here is the code if this chnges anything (Its in javascript):
var Player : Transform;
var MoveSpeed = 4;
var MaxDist = 10;
var MinDist = 5;
function Start ()
{
}
function Update ()
{
transform.LookAt(Player);
if(Vector3.Distance(transform.position,Player.position) >= MinDist){
transform.position += transform.forward*MoveSpeed*Time.deltaTime;
if(Vector3.Distance(transform.position,Player.position) <= MaxDist)
{
//Here Call any function U want Like Shoot at here or something
}
}
}
Comment
Answer by Wolfrik_Creations · May 10, 2016 at 07:34 AM
I can't really understand what you are saying, if you're saying what I presume then try replacing your LookAt line with LookAt (Vector3 (Player.position.x, transform.position.y, Player.position.z));
Your answer
Follow this Question
Related Questions
Enemy keeps floating throw roof? 0 Answers
enemy looking randomly? 0 Answers
Spawn a dot for every number typed? 0 Answers
Have FPS Controller Crouch to hide player? 1 Answer
Why wont this work? 0 Answers