Skip to content

Instantly share code, notes, and snippets.

@lena3rika
Created September 13, 2015 23:53
Show Gist options
  • Save lena3rika/50b37bbf4a97f6add237 to your computer and use it in GitHub Desktop.
Save lena3rika/50b37bbf4a97f6add237 to your computer and use it in GitHub Desktop.
using UnityEngine;
public class HoverTarget : MonoBehaviour
{
private Rigidbody2D rigidBody;
private bool stationary;
// Use this for initialization
void Start ()
{
rigidBody = GetComponent<Rigidbody2D> ();
stationary = true;
}
// Update is called once per frame
void Update ()
{
rigidBody.isKinematic = stationary;
}
void OnCollisionEnter2D(Collision2D collision)
{
if(collision.gameObject.tag == "Projectile")
{
stationary = false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment