#Idk what to call this

1 messages · Page 1 of 1 (latest)

cinder adder
#

Im trying to detect when the top slider part goes back

#

How would I detect this

#

Im pretty sure I would use Vector3 but I dont really understand how it works

#

all im trying to do is to detect when one point is moved a certain distance

#

I already made some things working that makes it so you can grab the top of the gun and move it back

#

Im using unity XR

#

I just need to detect when the player pulls back the slide

#

and then turn that into a bool

soft hound
#

A Vector3 is just a collection of three numbers

cinder adder
#

ok

sharp tusk
#

You can probably store the idle slider position (initial pos) and compare it to the current position of the slider in order to know what’s the travel distance so far

soft hound
#

If you want to detect when an object has moved a certain amount, subtract their original position from their current position and see if the difference is bigger than some number

cinder adder
#

how would I sample the original position

#

and the current

soft hound
#

Presumably this is a child object of something, so it's starting position is probably zero

cinder adder
#

The slide is set to only move on the x axis (relative to the rest of the gun)

sharp tusk
#

You can use the squareMagnitude of the resulting vector substract

#

Oh much easier in that case

sharp tusk
#

You only need to check the x value

cinder adder
#

ok

cinder adder
soft hound
#

If it's bigger than some amount, then you can set that boolean

cinder adder
#

ok

#

Ill try and write something and put it here to see if you guys think it would work

#

So would this be the transform of the original position or the position I want it to be to trigger the bool?

#

I really have no idea where I go from this

#

@soft hound @sharp tusk

#

watching a youtube video so I can understand it more

cinder adder
#

I still dont know how to do any of the things I nee dto