I am trying to rotate an object from one direction to other direction. How can we make it smooth rotation? Right now it is making a jumpy rotation with the following code. Thanks in advance
import bpy
import mathutils
context = bpy.context
scene = context.scene
obA = scene.objects.get("Cone")
obA["speed"] = 0.1
def setloc(scene):
a = bpy.data.scenes["Scene"].frame_current
if a < 60:
loc = mathutils.Vector((8.0, -0.05, 0.0))
dv = loc - obA.location
else:
loc = mathutils.Vector((-10.0, 14.05, 7.0))
dv = loc - obA.location
#rotation
rot_quat = dv.to_track_quat('Z', 'Y')
obA.rotation_euler = rot_quat.to_euler()
speed = obA["speed"]
if speed > 0.000001 and dv.length > 0.000001:
obA.location += speed * dv.normalized()
bpy.app.handlers.frame_change_post.clear()
bpy.app.handlers.frame_change_post.append(setloc)