kadyr

Untitled

Sep 18th, 2021
682
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class GuyMove : MonoBehaviour
  6. {
  7.     private Rigidbody rb; //получаем физику
  8.  
  9.     [SerializeField]
  10.     private float speed = 5f;
  11.  
  12.     private Vector3 direction;
  13.     private Vector3 startPosition;
  14.    
  15.     void Start()
  16.     {
  17.         startPosition = transform.position;
  18.         rb = GetComponent<Rigidbody>();
  19.     }
  20.  
  21.     void Update()
  22.     {
  23.         if (Input.GetKeyDown(KeyCode.Space))
  24.         {
  25.             rb.AddForce(transform.up * 10f, ForceMode.Impulse);
  26.         }
  27.  
  28.         if (transform.position.y < -10)
  29.             transform.position = startPosition;
  30.     }
  31. }
  32.  
RAW Paste Data