Advertisement
lemansky

Untitled

Feb 19th, 2021
788
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.77 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. // dobavete na Game Object nov kompoment RigidBody i sled tova dobavete tozi script, kato go naimenovate Movement
  6.  
  7. public class Movement : MonoBehaviour
  8. {
  9.     // Start is called before the first frame update
  10.     [SerializeField]
  11.     private float speed = 10.0f;
  12.     private Vector3 movement;
  13.     private Rigidbody rb;
  14.     // Start is called before the first frame update
  15.     void Start()
  16.     {
  17.         rb = this.GetComponent<Rigidbody>();
  18.     }
  19.  
  20.     // Update is called once per frame
  21.     void FixedUpdate()
  22.     {
  23.         //Debug.Log(speed);
  24.         movement = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
  25.         rb.AddForce(movement * speed);
  26.     }
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement