Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Need help! Enemy follows player with its head!

$
0
0
I have a huge problem. The enemy chases after the player headfirst. I have spent all morning (a full five hours) trying to fix this problem. I have tried to fix it with code, inspector properties, and even by reimporting the model from 3ds max. With the destruction of my ego, I have found no solution; therefore, I am hoping for a miracle that someone has had a similar problem and has found a solution. Here's my code just incase: #pragma strict var detectedCheck : EnemyVolumeOne; var willAttackCheck : boolean; var target : Transform; var moveSpeed = 4; var damping : float = 4; function Update () { detectedCheck = GetComponentInChildren(EnemyVolumeOne); if(detectedCheck.detected == true){ transform.LookAt(target); //player looks at me with wrong angle, i have the follow script right, but i need the enemy to follow me correctly. //IGNORE /*var relativePos = target.position - transform.position; var rotation = Quaternion.LookRotation(relativePos); transform.rotation = rotation;*/ //transform.eulerAngles = new Vector3(0,transform.eulerAngles.y,0); //transform.LookAt(target); /*var rotation = Quaternion.LookRotation(target.transform.position - transform.position); rotation.x = 0; transform.rotation = Quaternion.Slerp(transform.rotation,rotation,Time.deltaTime * damping);*/ //transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime *1); //transform.Translate(Vector3.up * moveSpeed * Time.deltaTime *-1); //transform.position += transform.up * moveSpeed * Time.deltaTime *-1; print("he's gonna get you"); } }

Viewing all articles
Browse latest Browse all 7934

Trending Articles