I have this two methods and they are working and I want to keep using them but the problem is that if the target the objectToMove is should reaching too far or very far the speed of the movement of the objectToMove will be fast but if the target to reach is very close or closer the objectToMove will move very very slow.
I want to have a constant speed that I can set the speed no matter what distance is the objectToMove from the target.
Because it’s working I want to keep it this way with the two methods just to change it that the speed will be the same no matter what is the distance between the objectToMove and the primaryTarget.
Not as before after the changes in both methods when the objectToThrow is coming back to the player hand now when the player is moving again when I’m moving the player the objectToThrow is not coming with the player hand it’s left behind and moving randomly jump strange. The objectToMove is a child and I’m moving it to a target(primaryTarget) then when it’s reaching the target the target is set to non active disable then the object should move back to the player hand.
primaryTarget.gameObject.SetActive(false);
I simulate this way a picking up object.
You can see it in this screenshot :
The NAVI object is child of Navi Parent. Both Navi Parent and NAVI positions are set to 0,0,0
NAVI is the object that move to the primaryTarget in this case it’s the Cube in the screenshot.
And NAVI is also moving back to the player hand back and should stay child of Navi Parent just move to the target and back.
The player hand object that holding NAVI is rig_f_middle.02.R (Navi Parent is child of rig_f_middle.02.R and NAVI is child of Navi Parent).
The problem is that the NAVI is child so the problem is to make it move to the target and back and keep staying child.
That is why in the second method I’m also doing :
objectToMove.localPosition = new Vector3(0, 0, 0);
To make sure the NAVI sill be child of the Navi Parent when moving the player again.
It’s not clean solution but it’s working. I could not find another way with sending the NAVI to the target and back it’s never returning to the hand at 0,0,0 and if I’m not setting it on my own to 0,0,0 then when moving the player the NAVI will not move with the hand fine.
After changing your lines solution in both methods ThrowObject and ThrowBack for some reason the NAVI is not returning to the hand fine and not moving with the players hand.
Before it did work fine but the sped was not fine.
I think you have labelled the variable “time” wrong. It’s a step, not time.
In that case you have to save the values of currentPos and originalPos so that it does not change on each loop.
Right now the currentPos is changing. Because it is being used inside the loop.