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

Projectiles always going to the left and not forward

$
0
0
Hi, I have a cube that is supposed to fire prefab cylinders which have a rigidbody. However, the cylinders are always coming out of the left side of the cube, instead of the front. I've tried changing the direction and using AddRelativeForce() but it will always come out of the left side. Could someone explain to me why that is? Thanks. void FixedUpdate () { speed = Input.GetAxisRaw("Horizontal") * acceleration; amountToMove = new Vector2(speed, 0); transform.Translate(amountToMove * Time.deltaTime); if(Input.GetButtonDown("Fire1")){ Debug.Log("Fire1 pressed!"); laser = Instantiate(laser, transform.position, transform.rotation) as GameObject; laser.rigidbody.AddForce(laser.transform.forward * Time.deltaTime); } }

Viewing all articles
Browse latest Browse all 1264

Trending Articles



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