i want my sphere character launched to the air when he hits collider. how to do this?
im new to unity and coding. so l have made a game where you use addforce to a sphere and it starts moving and the goal is to hit cubes. i want to launch the character to the air when the player hits a invisible collider to prevent the player from falling of the platform. How do i do this?
Comment
Answer by DigitalGuruReloaded · Nov 12, 2020 at 11:53 AM
its very easy you can write the code something like this first take the object and you want to collide the player with and move it to a new layer for example layer 11
the code something like this
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.layer == 11)
{
rigidbodycomponent.AddForce(Vector3.up * 20, ForceMode.VelocityChange);
}
and you can replace the number 20 with the force you want to apply