So as you can see this is my mini game project so far. Whenever the car jumps it just goes straight up and doesn't keep the same speed/momentum.
(Just another picture)
Here is my source.
Code:
using UnityEngine;
using System.Collections;
public class Jump : MonoBehaviour
{
public Rigidbody truck;
void Start()
{
truck = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
if (Input.GetKeyDown(KeyCode.B))
{
truck = GetComponent<Rigidbody>();
truck.velocity = new Vector3(0, 7, 0);
}
else if (Input.GetKeyDown(KeyCode.LeftControl)) {
truck.velocity = new Vector3(0, 3, 4);
}
}
}
Let me know if there is something I am missing. I am on 5.3.5f1,
Edit: I was able to fix the inertia/momentum flaw using this to set only the y axis to a different value.
Code:
rigidbody.velocity = new Vector3 (rigidbody.velocity.x, 10f, rigidbody.velocity.z);
Last edited by SantaClause on Tue Jun 07, 2016 10:02 am; edited 1 time in total (Reason for editing : Found fix.)