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

Why is rigidbody.addForce calling a Rigidbody2D function?

$
0
0
I'm trying to write a script that defines the motion of a player-type character in a 3D game by calling rigidbody.addForce, but the console is telling me that there is no Rigidbody2D attached. I'm aware of this, as there's a Rigidbody attached, not a Rigidbody2D, on purpose. I want this to be a 3D game. void FixedUpdate () { if (Input.GetKey (KeyCode.W)) { //forward rigidbody.AddForce(0, 0, 2); } if (Input.GetKey (KeyCode.S)) { //back rigidbody.AddForce(0, 0, -2); } if (Input.GetKey (KeyCode.A)) { //left rigidbody.AddForce(-2, 0, 0); } if (Input.GetKey (KeyCode.D)) { //right rigidbody.AddForce(2, 0, 0); } }

Viewing all articles
Browse latest Browse all 1264

Trending Articles



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