#grab physics
1 messages · Page 1 of 1 (latest)
making a thread
Do you need to know where your hand was in the last FixedUpdate, rather than where it was when you started the grab?
if i understand you correctly, yes? i set lastHandPosition (vector3) to hand position at the end of FixedUpdate
I'm asking you how your game is supposed to work!
like the locomotion?
I originally thought you wanted to know where the hand started
That would let you figure out where to position the player based on the current hand position, too
it wouldn't give you a velocity though
so basically i use overlap sphere, if it overlaps a collider, and you grab it, when you grab it, you offset the player by (lastHandPos - handTransform) / Time.fixedDeltaTime
when ungrabbed, it stops it
lastHandPos (vector3), is set at the end of FixedUpdate, and player offset is at the start
what im trying to figure out is how to fix that jitter when grabbing a moving object, and how to make so the player moves with that grabbed object too
@velvet ice
okay, so you can do this at the end of FixedUpdate:
localLastHandPos = grabbed.InverseTransformPoint(handPos);
and then at the start of FixedUpdate:
Vector3 lastHandPos = grabbed.TransformPoint(localLastHandPos);
lastHandPos is a world-space position.
If the grabbed transform moved, then lastHandPos will have moved
i have an attach point on the minecart, thats being set to handTransform when i grab the minecart
you mean grabbed as the object i grabbed? (aka attachPoint)
( @velvet ice )
grabbed is the Transform of the object you grabbed
okk
The idea is to record where your hand was from the point of view of the object
That way, no matter how the object moves, you can figure out the correct world-space position later
void FixedUpdate(){
LocalPlayer.GetGripHand(grabbingHand).handLastPosition = attachPoint.TransformPoint(localLastHandPos);
//Lever Logic
localLastHandPos = attachPoint.InverseTransformPoint(LocalPlayer.GetGripHand(grabbingHand).handTransform.position);
}
i did this, brb
@velvet ice gurl youre truly the sigma one, thanks sm
(it works)
nice (:
The Transform methods can be super useful.
Any time you find yourself trying to "offset" something because you're trying to use a different point of view, you probably need a transform method
i currently suck at physics in unity and transforms thats for sure
(but sometimes you just have to do it yourself)
i have a component that parents the knots of a Spline to transforms
so that the spline follows the transforms around
i was just so desperate because i been trying to get this to work for so long i didnt think of different perspectives
for (int index = 0; index < spline.Count; ++index)
{
BezierKnot knot = knots[index];
Transform parent = transforms[index];
positionOffsets.Add(parent.InverseTransformPoint(splineTransform.TransformPoint(knot.Position)));
Quaternion knotWorldRotation = splineTransform.rotation * knot.Rotation;
Quaternion toParentRotation = Quaternion.Inverse(parent.transform.rotation) * knotWorldRotation;
rotationOffsets.Add(toParentRotation);
}
mildly scary
are you talking about unity splines or?
i got curvy splines
Yeah, unity splines