One last hopeful bump on this! Nothing is working as far as local, well, anything goes. Haven't found anything that would make it work, either.
MsDoe
Recent community posts
Hello! Sorry to come back here with another question, but I have an issue.
I'm using the function actor.setOrientation(Sup.Math.Quaternion); in my constructor to set an origin angle for my actor, from which I was hoping I could locally rotate the actor (the actor is a spinning wheel). Later in the code, I call actor.rotateLocal(offset Sup.Math.Quaternion), but it does not rotate locally. Instead, it rotates globally.
I know that the orientation is working properly because the wheel does in fact rotate to where it is supposed to be; however, rotations are still global and not in reference to this orientation angle. Am I missing something?
Thanks! I ended up figuring this out when I realized that it wasn't pure JS that added the ability to have classes, it was TypeScript... so I was digging through the wrong documentation entirely. My issue is that I wasn't defining variables properly with name: type, and was instead doing let name = type;
Also, how would one be able to call on properties stored in an actor's behavior? Like, if I wanted to grab the velocity from an object's behavior and that property was public, how would I reference it? Calling Sup.Actor.getBehavior just returns the class itself, not the instance of the class that I'm trying to refer to.
class ballBehavior extends Sup.Behavior{
constructor(ball)
{
super(ball);
let ballActor = new Sup.Actor("Ball");
ballActor.setPosition(0, 0, 0);
let ballAngle = 0;
let ballPosition = new Sup.Math.Vector3;
let ballVelocity = 0;
ballActor.addBehavior(ballBehavior);
}
update(){
this.ballAngle += this.ballVelocity;
//Constrains the angle between 0 and 2pi
if(this.ballAngle > Math.PI * 2){
this.ballAngle = 0 + this.ballAngle - Math.PI * 2;
}else if (this.ballAngle < 0){
this.ballAngle = Math.PI - this.ballAngle + Math.PI * 2;
}
//Maybe a little spinback on the pointer?
this.ballPosition = new Sup.Math.Vector3(Math.cos(this.ballAngle) * wheelActor.getLocalScaleX() * 100 / 100,
Math.sin(this.ballAngle) * wheelActor.getLocalScaleX() * 100 / 100, 0);
if(Sup.Input.wasKeyJustPressed("LEFT")){
this.ballVelocity = 0.5;
}
}
}