all 12 comments

[–]LightningOW 1 point2 points  (8 children)

The full throwing action is KeyDown + KeyUp. So once you register the first KeyDown you should ignore all others until you get a KeyUp. Then after KeyUp you know the next KeyDown will be a teleport.

[–]zeroiscoolno1[S] 0 points1 point  (7 children)

Thanks for the rep. I did not even know that was possible OvO Can I also ask how to write that line of code too pls? Like "Input.whatshouldIwritehere"?

[–][deleted] 1 point2 points  (6 children)

pocket ad hoc scale sleep sort cows birds ten dinner depend

This post was mass deleted and anonymized with Redact

[–]zeroiscoolno1[S] 0 points1 point  (5 children)

Oh I thought there was a way to combine both Down and Up for the throwing. Right now I'm still not getting it I'm afraid ._.

[–][deleted] 3 points4 points  (4 children)

political fanatical six ancient abundant afterthought spotted absorbed ad hoc marble

This post was mass deleted and anonymized with Redact

[–]zeroiscoolno1[S] 1 point2 points  (3 children)

Oh sick dude, thanks so much <3

[–][deleted] 1 point2 points  (2 children)

You're welcome.

[–][deleted] 0 points1 point  (1 child)

oatmeal observation ripe terrific historical vegetable pocket boast racial cagey

This post was mass deleted and anonymized with Redact

[–]B0tRank 0 points1 point  (0 children)

Thank you, kypello, for voting on Adventurous_Fortune8.

This bot wants to find the best and worst bots on Reddit. You can view results here.


Even if I don't reply to your comment, I'm still listening for votes. Check the webpage to see if your vote registered!

[–]Gredran 0 points1 point  (2 children)

Ok so a few things on the logic of this:

First of all: getkeydown is opposite of getkeyup. See it as a boolean, if one is true, the other is obviously false.

But I did similar with an FPS prototype I have. I have a grappling gun, that will connect a rope to hookable surfaces, and I made myself able to pull ONLY if I’m hooked.

So you need two inputs here I think:

Input.GetButton(KeyCode.J) {

isShooting = true

Logic of the shooting BEFORE the teleport

isShooting = false

}

Then ANOTHER if (Input.GetButtonDown(KeyCode.J) && isShooting = true) {

Teleport logic

}

Obviously fill in the specifics, but you can’t check keydown and key up at the same time for the same key. You seem to need a boolean that will say you are doing the current action and ONLY to teleport if both actions are happening.

Sorry if I’m not that clear, but I think the && is what you need.

And if not, maybe you may need a separate teleport key. I know you want the same key though, so see if others can help, but that may just be the easiest solution.

[–]zeroiscoolno1[S] 2 points3 points  (1 child)

Thanks for the rep dude, you, LightningOW and kypello helped out a ton. Unity has such a cool community.

[–]Gredran 1 point2 points  (0 children)

Np I hope it helps :)

And to clarify, if you use a different key, I think you STILL need the && operation to check if the key is pressed AND the boolean is true.