Quantcast
Channel: Questions in topic: "javascipt"
Viewing all articles
Browse latest Browse all 1875

RigidBody.AddForce example in JavaScript

$
0
0
I can't seem to get the simple tutorial working with JavaScript. #pragma strict var rb; function Start () { rb = GetComponent(''); } function FixedUpdate () { var moveHorizontal = Input.GetAxis("Horizontal"); var moveVertical = Input.GetAxis("Vertical"); var movement = new Vector3(moveHorizontal, 0, moveVertical); rb.AddForce(movement); } keeps outputting: `Assets/PlayerController.js(15,12): BCE0019: 'AddForce' is not a member of 'Object'.` Perhaps it's my `GetComponent` usage? I'd appreciate some help. EDIT: Doesn't work either with `rb = GetComponent('RigidBody');`

Viewing all articles
Browse latest Browse all 1875

Trending Articles



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