rotateTowards How to use?
I am trying to use the rotateTowards function.. I think its the same function with moveTowards but I cant get it to work due to the errors. Here is my code
// -----JS CODE-----
//@input SceneObject Obj1
//@input SceneObject Obj2
var x = script.Obj1;
var y = script.Obj2;
var xtr = x.getTransform().getWorldPosition();
var ytr = y.getTransform().getWorldPosition();
var xrot = x.getTransform().getWorldRotation();
var yrot = y.getTransform().getWorldRotation();
var xtransform = x.getTransform().getWorldTransform();
var ytransform = y.getTransform().getWorldTransform();
var value = xtr.moveTowards(ytr,1);
var rot = xrot.rotateTowards(yrot,1);
var newtransform = x.getTransform().setWorldPosition(value);
var newrotation = x.getTransform().setWorldRotation(rot);
Reference:
https://lensstudio.snapchat.com/api/classes/vec3/#rotatetowardsvec3-point-number-amount-vec3
Thank you for the response
Hi Jhonnel,
In your code, xrot is a quat but the rotateTowards() function only exists on vec3. Maybe you want to use a quat function like quat.slerp()? https://lensstudio.snapchat.com/api/classes/quat/
Let me know if you need any more help!
Jacob
Thank you for the response Jacob, It works!! you're awesome