i am incredibly new and im trying to get the basics down such as moving my character. when i look at some tutorials all of em use vector3. i have a somewhat idea of how it works but i still have some questions to clarify. Code (CSharp): void Start() { rigidbodycomponent = GetComponent<Rigidbody>(); } // Update is called once per frame void Update() { //check if space key is down if (Input.GetKeyDown(KeyCode.Space)) { jumped = true; } horizontalinput = Input.GetAxis("Horizontal"); } // FixedUpdate is called once every physics update void FixedUpdate() { if (Physics.OverlapSphere(groundCheckTransform.position, 0.1f, playerMask).Length == 0) { return; } if (jumped) { rigidbodycomponent.AddForce(Vector3.up * 5, ForceMode.VelocityChange); jumped = false; } rigidbodycomponent.velocity = new Vector3(horizontalinput, rigidbodycomponent.velocity.y, 0); } here is my code right now. 1.i see that the last code is creates a new Vector3. so i wanna ask when will i have to create a new vector3 or will it only do it once for every object. like every object will only have one version of their own vector3 if u know what i mean. 2.how will i change my velocity later? if i set rigidbodycomponent.velocity here, do i just repeat the same thing but without the new keyword? 3.why did i not have to create a new vector3 when i made the object jump. and whats the difference between the AddForce function affecting the rigidbody, and creating a new vector3 and applying it to the velocity of the rigidbody directly. why didnt the code to make the object jump just change the velocity? thank you for your help in advance
Code (CSharp): if (jumped) { rigidbodycomponent.AddForce(Vector3.up * 5, ForceMode.VelocityChange); jumped = false; } Well, in fact you did use a Vector3 in the jump method. It just want declared as a 'new' vector3. Theres a lot of questions here that given a little more hands on, will all just make sense. Keep going, you'll get it!