Postingan

Menampilkan postingan dari September, 2022

Cara Move di Unity

Gambar
using System . Collections ; using System . Collections . Generic ; using UnityEngine ; public class InputScript : MonoBehaviour {     // Start is called before the first frame update     void Start ()     {             }     // Update is called once per frame     public Transform box ;     public float speed ;     void Update ()     {         if ( Input . GetKey ( KeyCode . W )){             float x = box . position . x + speed ;             float y = box . position . y ;             float z = box . position . z ;             box . position = new Vector3 ( x , y , z );         }         if ( Input . GetKey ( KeyCode . S )){             float x = box . position . x - speed ;             float y = box . position . y ;             float z = box . position . z ;             box . position = new Vector3 ( x , y , z );         }         if ( Input . GetKey ( KeyCode . A )){             float x = box . position . x ;             float y = box . position . y

Cara respawn di Unity 3D

Gambar
  using System . Collections ; using System . Collections . Generic ; using UnityEngine ; public class Script2 : MonoBehaviour {     public float c ;     public GameObject Sphere ;     public Rigidbody rb ;     // Start is called before the first frame update     void Start ()     {         rb = GetComponent < Rigidbody >();     }     // Update is called once per frame     void Update ()     {         if ( Input . GetKeyDown ( KeyCode . X )){             Instantiate ( Sphere , transform . position , Sphere . transform . rotation );         }     } }