- Home /
Question by
rOBY GAMES · Sep 28, 2015 at 07:53 PM ·
scripting problem
Unity 2d edit a scrip.
Hello everyone and can modify this script? This script is attached to the player. When I move the mouse cursor to the right or left, the player follows the 2D cursor. Everything is right, however, change the rotation of players. I would like to change this script by rotation localScale. You can modify this script? Thank you
using UnityEngine;
using System.Collections;
public class PlayerGuardaMano1 : MonoBehaviour {
public Transform player;
public Transform self; // object you want to face the player on x axis only
void Update ()
{ if (player.transform.position.x <= self.transform.position.x) //players spot in world space as opposed to enemy "self" spot
{ self.transform.localScale = new Quaternion(0,0,0,0);// flips enemy around to face the player on x axis only
}
else
if (player.transform.position.x >= self.transform.position.x)//players spot in world space as opposed to enemy "self" spot
{
self.transform.rotation = new Quaternion(0,180,0,0);// flips enemy around to face the player on x axis only
}
}
}
yes.png
(5.5 kB)
Comment