I did look at the forums and saw delay stuff but can’t figure how I would fit it into my script. Pretty simple. It’s a jump on mouse1 down and the script changes the collider so the player will actually be able to jump over things. Then on mouse1 up the collider goes back to normal. problem is that unlike keydown where you hold the key down, people have a tendancy to just click the mouse ( rather than hold the button down) thus…my collider returns to it’s original size too soon. So I would like to add a delay before the mouseup action takes place to keep the capsule collider smaller longer
using UnityEngine;
using System.Collections;
public class JumpColliderOff : MonoBehaviour {
void Update() {
if (Input.GetKeyDown(KeyCode.Mouse1))
GetComponent<CapsuleCollider>().height = .1f;
if (Input.GetKeyDown(KeyCode.Mouse1))
GetComponent<CapsuleCollider>().radius = .1f;
if (Input.GetKeyUp(KeyCode.Mouse1))
GetComponent<CapsuleCollider>().height = 1.7f;
if (Input.GetKeyUp(KeyCode.Mouse1))
GetComponent<CapsuleCollider>().radius = .3f;
}
}
You can use just a flag too and another attribute to calculate the time incresing the counter and checking the Time.time. As I said you can solve with a different solutions.
NOTE: In your codes you don’t need to verify 2 times the inputs if is the same thing that you are checking… Use a block with your if to
do all actions that you need.
Hmmmm. must have been a bug inside Unity. Restarted this morning and that very same script works fine, but it WAS the line about Vector3 auxCollider that Unity didn’t like yesterday. Loves it today. Thanks again. Wish I had posted this as another question so I could give you another “thumbs up” . tried clicking it again and it just toggles between 1 and 0