I am trying to make a weird request here. My problem is that I’m trying to make my character jump with Input.GetButtonDown(“Jump”) and being able to hover when i use Input.GetButton(“Jump”) after .25 secs of holding. Now the code works, but with a problem. If i hold Jump, I jump and after .25 secs I start to hover and stop at that spot and dont jump up any higher. I would like it to be, that when i press Jump and hold it, it just jumps. But when i let go and press Jump and hold jump while in the air he starts to hover. So the first time I press or press and hold jump, hover dosnt kick in and only when i press it agian will I then start to hover.
sorry but dosnt work. ive been playing around with counters and seem to get it kinda working. But i have to double press jump to get to start hovering while in the air.
Did i say the script doesn’t work? No. I said, it just “doesn’t work.” Meaning I tried it, modified it, and couldn’t get it to work. If your not going to say anything positive, please don’t say anything at all. I thought this place was to help people. Not to tell people what you despise.
k. I got the jump, hover thing, using a counter float. I couldn’t get it working with Dustins way tho. But i would like to know if there is a way to make it possiable, with jump, double jump, and a hover with 1 button.
GetkeyDown grounded = jump, GetKeyDown while in air = jump, and GetKey while in air = hover. Been playing with this all day here and there.
Got the jump and hover thing, but jump has to be doubled pushed while in the air for it to work.
I know there are numerous ways to do it, and wondering if I could get other people ideas to get this to work.
BTW I am using a rigidbody.
Also I started to learn unity and scripting only 4 weeks ago.
Yes, understanding how to manipulate 3D space (Vector) Positions is something you need to know, set a minimum and maximum float based on the up vector. If the vector = to more than a certain amount then a keypress will have a different action e.g. float…
lol checked out the links, and dam!. I am starting to understand how to use the reference script page to find answers. Ex, when i wanted to learn if counter floats were allowed. But a lot of it i don’t understand. The link to the vectors was a little (lol, a little is a understatement) over my head.
So,
private var hover : boolean;
private var jump : boolean;
private var doubleJump : boolean;
private var minDis : float = 1;
private var MaxDis : float =5;
if(Vector3.y < minDis)
{
jump = true;
}
if(Vector3.y > minDis)
{
jump = false;
doubleJump = true;
hover = true;
}
Something like that? Sorry but this is a lot of new information for me. Not sure how to use the maxDis float tho.
I’d suggest looking into “state machines”. The button needs different behaviour based on your current state. If you’re grounded you want it to transition to the jumping state, if you’re in the jumping/falling state you want it to transition to the hover state. State machines aren’t the only way to do this, but it’s probably what I’d do.
Get used to C# and even C++ if you can as well, it certainly won’t do you any harm…
But yes you are getting on the right track, always remember that a float is a attribute set by the dev so you need to know at what position you begin with and end with… Play around with vectors and transforms, there are various ways of even recording current vector positions dependant on what you need to do (E.g. screenpoint to ray (raycast) positions from location A to B … (Disclaimer I don’t use Unity anymore, or even PhysX) but the concept’s are all the same.
There’s so much you really need to start learning, it’s called the 10,000 hours of pain for a reason… Not saying you can’t get on with it well before that.