Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Jumper : MonoBehaviour {
- private bool isJumping = false;
- private Rigidbody rb;
- public Vector3 jumplength = new Vector3(0, 100, 0);
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update () {
- if(isJumping == true)
- {
- rb.AddForce(Vector3.up + jumplength);
- isJumping = false;
- }
- }
- private void OnTriggerEnter(Collider other)
- {
- if(other.gameObject.tag == "Player")
- {
- rb = other.gameObject.GetComponent<Rigidbody>();
- isJumping = true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment