0% found this document useful (0 votes)
3 views1 page

Using System Andar

The document contains a C# script for a PlayerController in Unity, which manages player movement and jumping mechanics. It uses Rigidbody2D for physics interactions, checks if the player is grounded, and updates animations based on movement and jump actions. Key functionalities include horizontal movement, jumping with a specified force, and updating the animator parameters for speed and grounded state.

Uploaded by

Higor Bonfim
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Using System Andar

The document contains a C# script for a PlayerController in Unity, which manages player movement and jumping mechanics. It uses Rigidbody2D for physics interactions, checks if the player is grounded, and updates animations based on movement and jump actions. Key functionalities include horizontal movement, jumping with a specified force, and updating the animator parameters for speed and grounded state.

Uploaded by

Higor Bonfim
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

using System.

Collections;
using [Link];
using UnityEngine;

public class PlayerController : MonoBehaviour


{
public float jumpForce = 5f;
public float moveSpeed = 5f;
private Rigidbody2D rb;
public Transform groundCheck;
public float checkRadius = 0.2f;
public LayerMask groundLayer;
private bool isGrounded;
public Animator animator;

void Start()
{
rb = GetComponent<Rigidbody2D>();
animator = GetComponent<Animator>();
}

void Update()
{
float horizontal = [Link]("Horizontal");

[Link] = new Vector2(horizontal * moveSpeed, [Link].y);

float velocidade = [Link]([Link].x);

// FORÇA PARAR A ANIMAÇÃO


if (horizontal == 0)
velocidade = 0;

[Link]("Speed", velocidade);

isGrounded = [Link]([Link], checkRadius,


groundLayer);

[Link]("isGrounded", isGrounded);

if ([Link]([Link]) && isGrounded)


{
[Link]([Link] * jumpForce, [Link]);
[Link]("Jump");
}
}
}

You might also like