#Directional swinging (again)

1 messages · Page 1 of 1 (latest)

ember spruce
#

how do i check if someone swings their hand horizontally to the right in front of them

urban cedar
#

This won't account too well for the curve of a swing but should still be good enough, plug the player's forward vector and up vector (or camera up vector camera, if you would like the "sideways" to be relative to their head rotation instead of body rotation) into a Vector3 Cross, this will get you a direction pointing sideways from the player. Run the player's hand velocity through Vector3 Normalize into a Vector3 Dot with that new sideways vector from before.

#

This should output a number closer to 1 the more your swing lines up with that sideways direction. If you want it to work both left and right, plug the result into an Absolute Value, then check if if it's accurate enough with a Greater Than.

#

If you only want to detect swings in one direction, skip the Absolute Value and plug the Vector3 Dot straight into the Greater Than. If it seems to be reversed (as in, outputs negative values when you swing in the desired direction) there are a couple ways you can deal with that, i heavily recommend just swapping the 2 inputs of the Vector3 Cross

mortal parrot
#

@ember spruce

urban cedar
#

The site doesn't yet have logic for changing all ports when connecting a certain data type to one, if you tried this in-game it wouldn't let you plug both of those into the Equals chip 😅

#

(among other things)

ember spruce
#

if not what does it do?

urban cedar
# ember spruce

Oh, you don't want to be detecting if the dot is greater than 1

#

Dots output a number between -1 and 1. The more similar two directions are, the closer it outputs to 1, the more opposite the closer to -1, and 0 is any direction perpendicular to it.

ember spruce
#

ic

urban cedar
#

Cross just gets you a direction "sideways" from to other directions, you dot the swing direction against that to see if it matches, you check if the result is greater than a certain amount, and can adjust that chip to change the accuracy needed.

#

I would suggest something around 0.8 or 0.9

ember spruce
#

so above 0 is sideways and below is downward im guessing?

urban cedar
#

1 means the directions are the same, -1 is opposite, 0 is perpendicular. So you're comparing it to a direction to the right of you, that means right equals 1, left equals -1, and anything perpendicular (up, down, forward, backwards) equals 0.

ember spruce
#

oh I see

urban cedar
#

Imagine drawing a circle around your head from front>down>back>up>front, any direction that lays along that circle would give 0

ember spruce
#

i can see the vision, lil confusing but i kinda get it

#

ty i might kiss you

urban cedar
#

One day i'd like to make tutorials and explanation vids and inventions of tools to help understand these concepts that people can mess around with themselves, but i've been pretty unmotivated for Rec Room especially now that i'm studying and will need to look for work later this year 😅

#

Oh also @ember spruce what are you connecting this to?

ember spruce
#

rn its in a thing where it changes the text to true/false

ember spruce
ember spruce
urban cedar
ember spruce
urban cedar
#

yee

limber gorge
#

to make circuits

urban cedar