I’m trying to make my object spin and I’m to stupid to find out what the code is to do it, and I’m not doing it with input, I just want it to spin on its own forever, example: Karlson
no, i just want it to spin on its own
no, i just want it to spin on its own.
Well in that case paste this into your function code
this.entity.rotateLocal(0,1,0)
You can increase the value to make it faster or decrease to make it slower if you want
won’t it only make it spin on the Y axis though?
or will changing the 0’s spin it along those axis’ too?
won’t it only make it spin on the Y axis though?
Yes you can put the zero on the X or Z axis as well?
Does the code work for you?
let me see
let me see you script paste it into a text
its literally just a standard script(if you had just created a new one) with that code in it
Hold on a second
var Spin = pc.createScript('spin');
// initialize code called once per entity
Spin.prototype.initialize = function() {
};
// update code called every frame
Spin.prototype.update = function(dt) {
};
this.entity.rotateLocal(0,1,0);
// initialize code called once per entity
Spin.prototype.initialize = function() {
};
// update code called every frame
Spin.prototype.update = function(dt) {
this.entity.rotateLocal(0,1,0);
};
alrighht i’ll try that
Does it work?
yes
Good job! glad to see you as a new developer on PlayCanvas. If you need help feel free to contact the forums or me directly.
ok, thank you for your help
Cheers
----Nicholas
oh, one more thing
if i did want it to be rotated on input(not like forever, but rotated a little bit and then stopped, then rotated back to the original rotation on key release), would it be
if (app.keyboard.isPressed(pc.KEY_E)) {
this.entity.rotateLocal(0,1,0);
}