Quantcast
Channel: Questions in topic: "addforce"
Viewing all articles
Browse latest Browse all 1264

Player isn't moving (AddForce) (Hook)(c#)

$
0
0
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); } } }

Viewing all articles
Browse latest Browse all 1264

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>