#Directional swinging (again)
1 messages · Page 1 of 1 (latest)
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
@ember spruce
That won't work, you're checking if a Vector3 equals a Quaternion
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)
i did all this but i’m just a lil confused on how it really works, like if editing the greater than giving more room to swing more higher or lower or smth
if not what does it do?
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.
ic
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
so above 0 is sideways and below is downward im guessing?
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.
oh I see
Imagine drawing a circle around your head from front>down>back>up>front, any direction that lays along that circle would give 0
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?
rn its in a thing where it changes the text to true/false
but then again it’s weird cuz it activates when my hand is stationary at a certain point
@urban cedar idk if it works as intended since this happens
Oh my god i totally forgot, you also need to detect the speed 🤦♂️
ah so greater than magnitude got it
yee
@limber gorge https://pckydev.github.io/Rec-Room-Circuits-API/editor