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

Error for playerPhysics

$
0
0
Hi, Im only new to unity so I cant find out what is wrong with this code. Thanks if anyone can help me it would be appreciated thanks. The error is: Assets/Scripts/PlayerController.cs(27,29): error CS1525: Unexpected symbol `playerPhysics' using UnityEngine; using System.Collections; [RequireComponent(typeof(PlayerPhysics))] public class PlayerController : MonoBehaviour { //Player Handling public float speed = 8; public float acceleration = 12; private float currentSpeed; private float targetSpeed; private Vector2 amountToMove; private PlayerPhysics playerPhysics; void Start () { playerPhysics = GetComponent(); } void Update () { targetSpeed = Input.GetAxisRaw ("Horizontal") * speed; currentSpeed = IncrementTowards(currentSpeed, targetSpeed,acceleration); amountToMove = new Vector2(currentSpeed,0) playerPhysics.Move(amountToMove * Time.deltaTimes); } // Increase n towards target by speed private float IncrementTowards(float n, float target, float a) { if (n == target) { return n; } else { float dir = Mathf.Sign(target - n); // must n be increased or decreased to get closer to target n += a * Time.deltaTime * dir; return (dir == Mathf.Sign(target-n))? n: target; // if n has now passed target then return target, otherwise return n } } }

Viewing all articles
Browse latest Browse all 7934

Trending Articles



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