Question by
CRAZYCR33P3R · Aug 18, 2017 at 12:45 AM ·
scripting problem2d animation
error CS0103 the name anim does not exist in current context
I'm trying to make a top down 2d game but this error pops up error CS0103: The name 'anim' does not exist in the current context and I have no clue what to do also this pops up The name 'movement_vector' does not exist in the current context and this is my script
using UnityEngine;
using System.Collections;
public class PlayerMovement : MonoBehaviour
{
public Rigidbody2D rbody;
public 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
Can you share the exactly error info? what line etc..