Hi,
Im wondering if anyone can help me this. I have a sword in a VR game attached to a hand. As I swing said sword it follows the hand. Problem is it follows the hand a little bit to slowly for my liking. I would like to change this so it feels more realistic or simply just faster.
What I did was dive into the SteamVr code to find the part of the code that updates its movement and what I found was this (SteamVr - Hand.cs Line 1161):
protected virtual void FixedUpdate()
{
if (currentAttachedObject != null)
{
AttachedObject attachedInfo = currentAttachedObjectInfo.Value;
if (attachedInfo.attachedObject != null)
{
if (attachedInfo.HasAttachFlag(AttachmentFlags.VelocityMovement))
{
if(attachedInfo.interactable.attachEaseIn == false ||
attachedInfo.interactable.snapAttachEaseInCompleted)
UpdateAttachedVelocity(attachedInfo);
// bunch of other code after an else statement
so I jumped and skipped down to that Method (SteamVr Hand.cs line 1212):
protected const float MaxVelocityChange = 10f;
protected const float VelocityMagic = 6000f;
protected const float AngularVelocityMagic = 50f;
protected const float MaxAngularVelocityChange = 20f;
protected void UpdateAttachedVelocity(AttachedObject attachedObjectInfo)
{
Vector3 velocityTarget, angularTarget;
bool success = GetUpdatedAttachedVelocities(attachedObjectInfo, out velocityTarget, out angularTarget);
if (success)
{
float scale = SteamVR_Utils.GetLossyScale(currentAttachedObjectInfo.Value.handAttachmentPointTransform);
float maxAngularVelocityChange = MaxAngularVelocityChange * scale;
float maxVelocityChange = MaxVelocityChange * scale;
attachedObjectInfo.attachedRigidbody.velocity = Vector3.MoveTowards(attachedObjectInfo.attachedRigidbody.velocity, velocityTarget, maxVelocityChange);
attachedObjectInfo.attachedRigidbody.angularVelocity = Vector3.MoveTowards(attachedObjectInfo.attachedRigidbody.angularVelocity, angularTarget, maxAngularVelocityChange);
Debug.Log("Moving");
}
}
I put the debug.log in there to make sure this was actually the call being made when I picked up my sword. Now The problem is that when I increase these numbers, regardless of what I do, the movement is not changed at all, not slower or faster. Im wondering what I can be doing wrong.