Trying to just rotate an object, but it is also scaling
This is really strange. I have a very simple script that only rotates an object attached to the head on update. For some reason, though, it is also scaling the object attached to the head.
If I create a new project, add a head binding and then add a cube with this script on it, this is what is happening: https://youtu.be/uLT74zKfmjc
Here's the script:
// -----JS CODE-----
// @input float rotateSpeed
var transform = script.getTransform();
var updevent = script.createEvent("UpdateEvent");
var rot = transform.getLocalRotation();
updevent.bind(function (eventData)
{
rot.y += script.rotateSpeed * eventData.getDeltaTime();
transform.setLocalRotation(rot);
});
Here try this one
//@input vec3 Rotation
//@input float Speed
// Equivalent to GameObject
var object = script.getSceneObject();
// Just like Unity Transform!
var transform = script.getTransform();
function onUpdate(ev) {
var transform = script.getTransform();
var rotation = transform.getLocalRotation();
var amt = script.Rotation.uniformScale(getDeltaTime() * script.Speed);
var rotateY = quat.angleAxis(amt.x, vec3.up());
var rotateX = quat.angleAxis(amt.y, vec3.left());
var rotateZ = quat.angleAxis(amt.z, vec3.forward());
rotation = rotation
.multiply(rotateY)
.multiply(rotateX)
.multiply(rotateZ);
transform.setLocalRotation(rotation);
}
var updateEvent = script.createEvent("UpdateEvent");
updateEvent.bind(onUpdate);
I get an error:
14:26:55.667 [Scenarium] TypeError: cannot read property 'uniformScale' of undefined
at onUpdate (Rotator.js:25) preventsyield
looks fine on my screen and rotations are going fine if anything just use a behavior script
Okay. Bizarre. I uninstalled and reinstalled LensStudio and tried your script again in the same project and it works now. Thanks!
Your Welcome :)