Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class BouncerLeft : MonoBehaviour
- {
- public float horizontalBounce = -15.0f;
- public float upBounce = 10.0f;
- GameObject player;
- // Start is called before the first frame update
- void Start()
- {
- player = GameObject.FindGameObjectWithTag("Player");
- }
- private void OnTriggerEnter2D(Collider2D collision)
- {
- player.GetComponent<Rigidbody2D>().velocity = -player.GetComponent<Rigidbody2D>().velocity;
- player.GetComponent<Rigidbody2D>().AddForce(new Vector2(horizontalBounce, upBounce), ForceMode2D.Impulse);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement