Advertisement
tomicz

Untitled

Jul 4th, 2016
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class ObstacleJump : MonoBehaviour {
  5.  
  6. public float moveVelocity;
  7. public float jumpVelocity;
  8. public float x;
  9. public float y;
  10. private Rigidbody2D accessGameObject;
  11.  
  12. void Start()
  13. {
  14. accessGameObject = GetComponent<Rigidbody2D>();
  15. var accessTransform = GetComponent<Transform>();
  16. accessTransform.transform.position = new Vector2(x, y);
  17. }
  18.  
  19. void Update()
  20. {
  21. accessGameObject.velocity = new Vector2(moveVelocity, transform.position.y);
  22. }
  23.  
  24. private void OnTriggerEnter2D(Collider2D jobstacle)
  25. {
  26. if (jobstacle.gameObject.tag == "Player")
  27. {
  28. accessGameObject.velocity = new Vector2(transform.position.x, jumpVelocity);
  29. Debug.Log("Player triggered");
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement