Hi, How i can make a Interpolation between two values?(python)
I’m planning on using this on 2 things:
1)I make a grab system for my game, basically:
-A ray is used for get the Object, and store the name in a property
-If you press click, and is there a object in the property mentioned above:
-A varible used for get if you are grabbing a object is changed to True.
-Move the Object to a empty in front of the camera.
-Deactivate the ability to rotate the object(practically convert the physics of the object, from a rigid body to a dynamic)
-Create a constraint.
So, the system work good, but i want to make the transition “smooth”, between the position of the object to the position of the empty.
2)When an object is in the crosshairs, the crosshairs activate a animation that makes rotate from one side to the other, but when the animation stop i want to make the crosshairs obtain the default rotation, in a smooth manner.
The second question, How apply a force to a object, but using a axis of other object? I will use it for throw the grabbed object.
So the aim is to move an object from an arbitrary location to an empty smoothly?
Vector math makes things really easy
target_obj = .....
empty_obj = .....
dist, global_vect, local_vect = target_obj.getVectTo(empty_obj)
move_vect = global_vect/2 #Move half the distance each frame. Possibly 1/5 would be better? Play around a little
target_obj.applyMovement(move_vect, False)
Off the top of my head, I can’t remember if the vectors returned by getVectTo are normalized, so you may need to add:
I like your gadget, I saw the code and the system for atract the object is basically @sdfgeoff what said.
Thanks to @Monster , now just i need the second answer …I think is similar to the solution of the first question, and i no have a clear idea of which is a vector.
PD: Almost forgot this …how make a object rotate to a specific value smoothly?
I guess that’s for the rotation, i test and what do is align the object, but how apply the force to the object using an object axis of another object? i need to apply the force, but without align the object.
PD: thanks for the link, i have a more clear idea of what is a vector!