Quantcast
Viewing all articles
Browse latest Browse all 2891

the code wont work for switching animation's and keep gettings errors

hello im very new to coding and unity and right now im making a stickman game but there's one problem when i did some code to make it so that when you walk you do the walk animation and when you stop walking it goes back to idle animation here's the code [CODE] using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerController : MonoBehaviour { public float speed; public float jumpForce; private float moveInput; private Animator anim; private Rigidbody2D rb; private void Start() { anim = GetComponent(); rb = GetComponent(); } void FixedUpdate() { moveInput = Input.GetAxis("Horizontal"); rb.velocity = new Vector2(moveInput * speed, rb.velocity.y); } if (moveInput == 0) { anim.SetBool("isRunning", false); } else { anim.SetBool("isRunning", true); } }

Viewing all articles
Browse latest Browse all 2891

Trending Articles



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