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

error sc0111 player_movement already defines member a member called "Grounded" with the same parameter types

$
0
0
I keep getting an errors like the ones in the title in my movement script. Does anybody know what's wrong and can give me a fix? None of the other scripts use "grounded" in them. public class Player_Movement : MonoBehaviour { private Rigidbody2D rb; private BoxCollider2D coll; private SpriteRenderer sprite; private Animator anim; [SerializeField] private LayerMask jumpableGround; private enum Koging { idle, running, jumping, falling, Attacking } private float dirX = 0; [SerializeField] private float Running = 7f; [SerializeField] private float Skrumphjump = 9f; // Start is called before the first frame update void Start() { rb = GetComponent(); sprite = GetComponent(); anim = GetComponent(); coll = GetComponent(); } // Update is called once per frame void Update() { dirX = Input.GetAxis("Horizontal"); rb.velocity = new Vector2(dirX * Running, rb.velocity.y); if (Input.GetButtonDown("Jump") && Grounded()) { rb.velocity = new Vector2(rb.velocity.x, Skrumphjump); } UpdateAnimationState(); } private void UpdateAnimationState() { Koging state; if (dirX > 0f) { state = Koging.running; sprite.flipX = false; } else if (dirX < 0f) { state = Koging.running; sprite.flipX = true; } else { state = Koging.idle; } if (rb.velocity.y > .001f) { state |= Koging.jumping; } else if (rb.velocity.y < -.001f) { state |= Koging.falling; } //if (Input.GetMouseButtonDown(0)) // { // state = Koging.Attacking; //} anim.SetInteger("state", (int)state); } private bool Grounded() { return Physics2D.BoxCast(coll.bounds.center, coll.bounds.size, 0f, Vector2.down, .1f, jumpableGround); } }

Viewing all articles
Browse latest Browse all 2891

Trending Articles



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