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

Rigidbody2D.AddForce is not moving the object

$
0
0
I'm trying to make a projectile move using its Rigidbody. I've looked at quite a few responses on this forum, but no matter what I try, the projectile does not move. I've tried Vector3.forward * force and transfrom.right * force, neither one works. Also, I've tried setting force to as high as 1000, again, with no luck. Any help is appreciated. using UnityEngine; using System.Collections; public class Fire : MonoBehaviour { public float force; public GameObject projectile; public GameObject RocketLauncher; //Use this for initialization void Start () { projectile.transform.rotation = new Quaternion(RocketLauncher.transform.rotation.x,RocketLauncher.transform.rotation.y,RocketLauncher.transform.rotation.z-90,RocketLauncher.transform.rotation.w); } //Update is called once per frame void Update () { if (Input.GetKeyDown("space")) { projectile.GetComponent().AddForce(transform.right * force); } } }

Viewing all articles
Browse latest Browse all 1264

Trending Articles



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