CarlosWGama

PlayerController 3D

Sep 9th, 2022 (edited)
1,509
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class PlayerController : MonoBehaviour
  4. {
  5.     [Header("Configurações de Movimento")]
  6.     public float velocidadeMovimento = 5f;
  7.     public float velocidadeRotacao = 100f;
  8.  
  9.     void Update()
  10.     {
  11.         // Obtém a entrada dos eixos (Setas do teclado ou WASD)
  12.         float translation = Input.GetAxis("Vertical") * velocidadeMovimento * Time.deltaTime;
  13.         float rotation = Input.GetAxis("Horizontal") * velocidadeRotacao * Time.deltaTime;
  14.  
  15.         // Move o personagem para frente ou para trás no eixo Z local
  16.         transform.Translate(0, 0, translation);
  17.  
  18.         // Rotaciona o personagem em torno do eixo Y local (estilo tanque)
  19.         transform.Rotate(0, rotation, 0);
  20.     }
  21. }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment