Advertisement
lemansky

Untitled

Mar 26th, 2021
917
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class PlayerController : MonoBehaviour
  6. {
  7.     public float speed = 10.0f;
  8.     Rigidbody rb;
  9.     [SerializeField]
  10.     private Vector3 movement;
  11.  
  12.     void Start()
  13.     {
  14.         rb = this.GetComponent<Rigidbody>();
  15.     }
  16.  
  17.     void Update()
  18.     {
  19.         movement = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
  20.         //transform.Translate(movement * speed * Time.deltaTime);
  21.     }
  22.  
  23.     private void FixedUpdate()
  24.     {
  25.         //rb.AddForce(movement * speed);
  26.         //rb.velocity = movement * speed;
  27.         rb.MovePosition(transform.position + (movement * speed * Time.deltaTime));
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement