i wanna make the player which is a ball jump when it touches particular cubes ,but not using bouncing
because it doesn’t give the same value of jump every time
and thanks
You could try
1.making a custom tag for the cube that allows you to jump and call it something like “Jumpable”
2.make a script, or edit your player script and add this.
public float jumpPower = 5f;
bool hit;
public Rigidbody rb;
void Start()
{
rb = GetComponent<Rigidbody>();
//or just assign the rigidbody yourself
}
void OnCollisionEnter(Collision col)
{
if (col.transform.tag == "Jumpable")
hit = true;
}
void OnCollisionExit(Collision col)
{
if (col.transform.tag == "Jumpable")
hit = false;
}
void Update()
{
if (hit)
{
rb.AddForce(0f,jumpPower,0f,ForceMode.Accelaration);
}
}
THEN:
Assign this script to your player’s COLLIDER, not the OBJECT ITSELF. be sure to assign the players rigidbody in the inspector to the script