I created a little script that shoots simple spheres as hook. When the hook hits something, it stop moving. And now the player should get pulled to the "hook", but nothing happens...
Here is the Code, which is placed on the hook itself:
using UnityEngine;
using System.Collections;
public class OnHook : MonoBehaviour {
public GameObject player;
public GameObject hook;
public float speed = 20;
public bool grabed = false;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter(Collider col){
if(col.tag != "Player" && col.tag != "Hook")
{
grabed = true;
rigidbody.velocity = Vector3.zero;
player.transform.rigidbody.AddForce((player.transform.position - hook.transform.position).normalized * speed);
}
}
}
↧