Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

How to fix error CS1061?

$
0
0
I am new to unity and have been stuck on this error for 2 months now using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerMovement : MonoBehaviour { private Rigidbody2D rb; private Animator anim; private SpriteRenderer sprite; private float dirX = 0f; [SerializeField] private float moveSpeed = 7f; [SerializeField] private float jumpForce = 6f; private enum MovementState { idle, jumping, running, falling } MovementState state = MovementState.idle; // Start is called before the first frame update private void Start() { rb = GetComponent(); anim = GetComponent(); sprite = GetComponent(); } // Update is called once per frame private void Update() { dirX = Input.GetAxisRaw("Horizontal"); rb.velocity = new Vector2(dirX * moveSpeed, rb.velocity.y); if (Input.GetButtonDown("Jump")) { rb.velocity = new Vector2(rb.velocity.x, jumpForce); } UpdateAnimationState(); } private void UpdateAnimationState() { //MovementState state; if (dirX > 0f) { state = MovementState.running; sprite.flipX = false; } else if (dirX < 0f) { state = MovementState.running; sprite.flipX = true; } else { state = MovementState.idle; } if (rb.velocity.y > .1f) { state = MovementState.jumping; } else if (rb.velocity.y < -.1f) { state = MovementState.falling; } anim.SetInterger("state", state); } Please help, I want to continue coding.

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>