#Idk what to call this
1 messages · Page 1 of 1 (latest)
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
A Vector3 is just a collection of three numbers
ok
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
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
how would I write that
could do this too
how would I sample the original position
and the current
Presumably this is a child object of something, so it's starting position is probably zero
You can get the current position with this:
https://docs.unity3d.com/ScriptReference/Transform-localPosition.html
The slide is set to only move on the x axis (relative to the rest of the gun)
You can use the squareMagnitude of the resulting vector substract
Oh much easier in that case
ok
You only need to check the x value
ok
so i check the x value with this and then compare it to the x value I want it to be to set a bool to true?
Yes, get the current X position, subtract the original X position, and that's your difference
If it's bigger than some amount, then you can set that boolean
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
helped but not all the way
I still dont know how to do any of the things I nee dto