Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class ObstacleJump : MonoBehaviour {
- public float moveVelocity;
- public float jumpVelocity;
- public float x;
- public float y;
- private Rigidbody2D accessGameObject;
- void Start()
- {
- accessGameObject = GetComponent<Rigidbody2D>();
- var accessTransform = GetComponent<Transform>();
- accessTransform.transform.position = new Vector2(x, y);
- }
- void Update()
- {
- accessGameObject.velocity = new Vector2(moveVelocity, transform.position.y);
- }
- private void OnTriggerEnter2D(Collider2D jobstacle)
- {
- if (jobstacle.gameObject.tag == "Player")
- {
- accessGameObject.velocity = new Vector2(transform.position.x, jumpVelocity);
- Debug.Log("Player triggered");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement