ScratchData LogoScratchData
Back to SelfManagedLearning's profile

Little Buddy vibes to Cucuí Ganon - Suavemente (Elvis Crespo Cover)

SESelfManagedLearning•Created October 12, 2021
Little Buddy vibes to Cucuí Ganon - Suavemente (Elvis Crespo Cover)
1
1
17 views
View on Scratch

Instructions

using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerController : MonoBehaviour { public float moveSpeed; public float jumpForce; public int jumpsAmount; int jumpsLeft; public Transform GroundCheck; public LayerMask GroundLayer; bool isGrounded; float moveInput; Rigidbody2D rb2d; float scaleX; // Start is called before the first frame update void Start() { rb2d = GetComponent<Rigidbody2D>(); scaleX = transform.localScale.x; } // Update is called once per frame void Update() { moveInput = Input.GetAxisRaw("Horizontal"); Jump(); } private void FixedUpdate() { Move(); } public void Move() { Flip(); rb2d.velocity = new Vector2(moveInput * moveSpeed, rb2d.velocity.y); } public void Flip() { if (moveInput > 0) { transform.localScale = new Vector3(scaleX, transform.localScale.y, transform.localScale.z); } if (moveInput < 0) { transform.localScale = new Vector3((-1)*scaleX, transform.localScale.y, transform.localScale.z); } } public void Jump() { if (Input.GetKeyDown(KeyCode.Space)) { CheckIfGrounded(); if (jumpsLeft > 0) { rb2d.velocity = new Vector2(rb2d.velocity.x, jumpForce); jumpsLeft--; } } } public void CheckIfGrounded() { isGrounded = Physics2D.OverlapCircle(GroundCheck.position, GroundCheck.GetComponent<CircleCollider2D>().radius, GroundLayer); ResetJumps(); } public void ResetJumps() { if (isGrounded) { jumpsLeft = jumpsAmount;// jumpsAmount =2; } } }

Description

https://scratch.mit.edu/projects/546559541

Project Details

Project ID582713886
CreatedOctober 12, 2021
Last ModifiedOctober 13, 2021
SharedOctober 12, 2021
Visibilityvisible
CommentsAllowed

Remix Information

Parent ProjectView Parent
Root ProjectView Root