- Home /
help with error CS0246
Assets/script/player controller.cs(16,10): error CS0246: The type or namespace name `PlayerPhysics' could not be found. Are you missing a using directive or an assembly reference?
.........................................................................................................................................................
using UnityEngine; using System.Collections;
[RequireComponent(typeof(playerphysics))] public class Playercontroller : MonoBehaviour {
//Player Handling public float gravity = 20; 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.x = currentSpeed;
amountToMove.y -= gravity * Time .deltaTime;
playerphysics.Move(amountToMove * Time.deltaTime);
}
//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
}
} }
Based on rutter's answer to your last question (http://answers.unity3d.com/questions/609535/how-do-i-fix-error-cs1526.html), do you see which line(s) are causing the problem?
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How to make FPS trailer? 1 Answer
How to have animation play correctly 1 Answer
GameObject' does not contain a definition for `Find' 1 Answer