Answers for "how to move player with transform. position"

C#
14

unity set position

// To set the position of a gameobject use the following
GameObject.transform.position = new Vector3(x, y, z);
Posted by: Guest on February-22-2020
0

how to move player with transform. position

public class bbo2 : MonoBehaviour
{

    private const float _minimumHeldDuration = 0.25f;
    private float _holdPressedTime = 0.5f;
    


    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetButton("m"))
        {
            if (Time.timeSinceLevelLoad - _holdPressedTime > _minimumHeldDuration)
            {
                transform.position += new Vector3(10f, 0, 0) * Time.deltaTime;
            }
        }
    }
}
Posted by: Guest on November-04-2021

Code answers related to "how to move player with transform. position"

C# Answers by Framework

Browse Popular Code Answers by Language