Assets/script/PlayerController.cs(15,10): error CS0246: The type or namespace name `PlayerPhysics’ could not be found. Are you missing a using directive or an assembly reference?
there are my two scripts
…
playercontroller
…
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<PlayerPhysics>();
}
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
}
}
}
...............................
player physics script
.....................................
sing UnityEngine;
using System.Collections;
[RequireComponent (typeof(BoxCollider))]
public class playerphysics : MonoBehaviour {
public LayerMask collisionMask;
private BoxCollider collider;
private Vector3 s;
private Vector3 c;
private float skin = .005f;
[HideInInspector]
public bool grounded;
Ray ray;
RaycastHit hit;
void Start() {
collider = GetComponent<BoxCollider>();
s = collider.size;
c = collider.center;
}
public void Move(Vector2 moveAmount) {
float deltaY = moveAmount.y;
float deltax = moveAmount.x;
Vector2 p = transform.position;
for (int i = 0; i<=3; i ++) {
float dir = Mathf.Sign(deltaY);
float x = (p.x + c.x - s.x/2) + s.x/2 * i; // Left,centre and then rightmost point of collider
float y = p.y + c.y + s.y/2 * dir; // Bottom of collider
ray = new Ray(new Vector2(x,y), new Vector2(0,dir));
if (Physics.Raycast(ray,out Hit.Mathf.Abs(deltaY).collisionorMask)) {
//Get Distance between player and ground
float dst = Vector3.Distance(ray.origin, hit.point);
//Stop player's downwards movement after coming within skin width of a collider
if(dst > skin) {
deltaY = dst + skin;
}
else {
deltaY =0;
}
grounded = true;
break;
}
}
Vector2 finalTransform = new Vector2(deltax,deltaY);
transform.Translate(finalTransform);
}
}