Question by
Maso10n1 · Apr 29, 2017 at 01:37 AM ·
charactercharactercontrollercharacter controllercharacter movement
Error CS0103
Ok, so I am putting together a 2D character movement script with animation, but it is coming up with the above error... The script is below... Can anyone help please?
using System.Collections;
using UnityEngine;
public class PlayerMovement : MonoBehaviour {
RigidBody2D rbody;
Animator anim;
// Use this for initialization
void Start () {
rbody = GetComponent<RigidBody2D> ();
anim = GetComponent<Animator> ();
}
// Update is called once per frame
void Update () {
Vector2 movement_vector = new Vector2 (Input.GetAxisRaw ("Horizontal"), Input.GetAxisRaw ("Vertical"));
if (movement_vector != Vector2.zero) {
anim.SetBool ("iswalking", true);
anim.SetFloat ("input_x", movement_vector.x);
anim.SetFloat ("input_y", movement_vector.y);
} else {
anim.SetBool ("iswalking", false);
}
rbody.MovePosition (rbody.position + movement_vector * Time.deltaTime);
}
}
Comment
Well, I don't know if this is the cause of your issue, but I noticed you are calling RigidBody2D incorrectly. The "b" in body should be lowercase. Also, it might help if you post the full error message that you are getting.
Your answer
Follow this Question
Related Questions
Character moves opposite ways.,My character moves perfectly to every direction except -z. 0 Answers
Character object is unstable and I can't figure out why or how to fix it 0 Answers
Rotate on key press to an end 0 Answers
I can't rotate and move in the opposite direction with character Controller 0 Answers