Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
12 views1 page

Cod Jump

The C# code defines a hero class that inherits from MonoBehaviour, gets a Rigidbody2D component in Start, and resets velocity to zero and applies an upward force when colliding with an object tagged as 'platform'.

Uploaded by

TMarian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views1 page

Cod Jump

The C# code defines a hero class that inherits from MonoBehaviour, gets a Rigidbody2D component in Start, and resets velocity to zero and applies an upward force when colliding with an object tagged as 'platform'.

Uploaded by

TMarian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

public class hero : MonoBehaviour

{
Rigidbody2D rb;

void Start()
{
rb = GetComponent<Rigidbody2D> ();
}

void Update()
{

}
void OnCollisionEnter2D(Collision2D other)
{
if (other.gameObject.tag == "platform")
{
rb.velocity=Vector2.zero;
rb.AddForce(transform.up * 20, ForceMode2D.Impulse);
}
}
}

You might also like