You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
825 B
36 lines
825 B
/*
|
|
this script is attached to ammo, and stores data to be used by the PickUpItemScript
|
|
*/
|
|
|
|
using UnityEngine;
|
|
using System.Collections;
|
|
|
|
public class AlwaysFace : MonoBehaviour {
|
|
|
|
|
|
public GameObject Target;
|
|
public float Speed;
|
|
|
|
public bool JustOnStart = false;
|
|
|
|
// turn towards target
|
|
void Start()
|
|
{
|
|
Vector3 dir = Target.transform.position - transform.position;
|
|
Quaternion Rotation = Quaternion.LookRotation(dir);
|
|
|
|
gameObject.transform.rotation = Rotation;
|
|
}
|
|
|
|
// turn towards target
|
|
void FixedUpdate ()
|
|
{
|
|
if (JustOnStart == false && Target != null)
|
|
{
|
|
Vector3 dir = Target.transform.position - transform.position;
|
|
Quaternion Rotation = Quaternion.LookRotation(dir);
|
|
|
|
gameObject.transform.rotation = Quaternion.Lerp (gameObject.transform.rotation,Rotation,Speed * Time.deltaTime);
|
|
}
|
|
}
|
|
}
|