Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

i keep getting a nullrefrence error and i dont know what to do can anyone help me please

$
0
0
i need help i keep getting an error saying "NullReferenceException: Object reference not set to an instance of an object TestMovement2.MovePlayer () (at Assets/TestMovement2.cs:48) TestMovement2.FixedUpdate () (at Assets/TestMovement2.cs:33)" here's the script using System.Collections; using System.Collections.Generic; using UnityEngine; public class TestMovement2 : MonoBehaviour { [Header ("Movement")] public float moveSpeed; public Transform Orientation; float horizontalInput; float verticalInput; Vector3 moveDirection; Rigidbody rb; void start () { rb = GetComponent(); rb.freezeRotation = true; } private void Update() { MyInput(); } private void FixedUpdate () { MovePlayer(); } private void MyInput() { horizontalInput = Input.GetAxisRaw("Horizontal"); verticalInput = Input.GetAxisRaw("Vertical"); } private void MovePlayer() { //calculate movement direction moveDirection = Orientation.forward * verticalInput + Orientation.right * horizontalInput; rb.AddForce(moveDirection.normalized * moveSpeed * 10f, ForceMode.Force); } } using System.Collections; using System.Collections.Generic; using UnityEngine; public class TestMovement2 : MonoBehaviour { [Header ("Movement")] public float moveSpeed; public Transform Orientation; float horizontalInput; float verticalInput; Vector3 moveDirection; Rigidbody rb; void start () { rb = GetComponent(); rb.freezeRotation = true; } private void Update() { MyInput(); } private void FixedUpdate () { MovePlayer(); } private void MyInput() { horizontalInput = Input.GetAxisRaw("Horizontal"); verticalInput = Input.GetAxisRaw("Vertical"); } private void MovePlayer() { //calculate movement direction moveDirection = Orientation.forward * verticalInput + Orientation.right * horizontalInput; rb.AddForce(moveDirection.normalized * moveSpeed * 10f, ForceMode.Force); } } Please help me

Viewing all articles
Browse latest Browse all 2891

Trending Articles



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