- Home /
Question by
Thunderturtle712 · Mar 10, 2014 at 11:45 PM ·
2dside-scrollingscripterror
error CS1061: Type `PlayerPhysics' does not contain a definition for `Move' and no extension method `Move' of type `PlayerPhysics' could be found (are you missing a using directive or an assembly reference?)
What the heck is this? What kind of error asks me a question?(rhetorical) well here is my script.
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(PlayerPhysics))]
public class PlayerController : MonoBehaviour {
public float speed = 8;
public float acceleration = 12;
private float currentSpeed;
private float targetSpeed;
private Vector2 amountToMove;
private PlayerPhysics playerPhysics;
// Use this for initialization
void Start () {
playerPhysics = GetComponent<PlayerPhysics>();
}
// Update is called once per frame
void Update () {
targetSpeed = Input.GetAxisRaw ("Horizontal") * speed;
currentSpeed = IncrementTowards (currentSpeed, targetSpeed, acceleration);
amountToMove = new Vector2 (currentSpeed, 0);
playerPhysics.Move (amountToMove * Time.deltaTime); //this is the line it says
}
private float IncrementTowards(float n, float target, float speed) {
if (n == target) {
return 0;
} else {
float dir = Mathf.Sign (target - n);
n += Time.deltaTime * dir;
return (dir == Mathf.Sign (target - n)) ? n : target;
}
}
}
Comment
Answer by robertbu · Mar 10, 2014 at 11:47 PM
According to the compiler, the PlayerPhysics class (which you don't show), does not have a 'Move' method. You need to look at the PlayerPhysics class what is going on. If it does have a 'Move' method, search your project to see if you have more than one PlayerPhysics script.
thank you. What happened is that I didn't save my playerPhysics script.
Your answer
Follow this Question
Related Questions
Scrolling Repeated Background - background is scrolling but not repeating 0 Answers
How To Make 2D Side Scrolling Game 3 Answers
Constraining Physics 3 Answers