Teleport But Only Rotation

Is there possibly a way to rotate a dynamic rigidbody? Or a way to use the rigidbody.teleport() method without setting the position? I tried setting the position just to its own position, but it made the rigidbody very glitchy.

Hi @wetnoodle111! Can you show what you have right now?

You can set it to the same position. It doesn’t matter if you just want rotation because under the hood, it just sets the whole transform any way

Yes, of course, thank you for your help:

Yes, I tried that, but it seems to make it very glitchy (though it may be glitching for another reason).

I think the problem is that you do it right after applying a force, so it will probably break the force. Maybe you can try to change the order?

K, I just rearranged some code. However, now it is not detecting the mouse moving at all in the movement script. Is there something I’m missing?

I have no idea. I don’t know what else you are doing and what you try to achieve. Switching the last two rules should not effect the mouse move event.

I used another mouse move event in my movement script. Here is the code in my movement script:

var Movement = pc.createScript('movement');
    type: 'number',
    default: 1,
    min: 0,
    max: 100,
    precision: 2
let rb; 
let forward;
let temp;
let right;
let q2;
let mouseX;
// initialize code called once per entity
Movement.prototype.initialize = function() {

// update code called every frame
Movement.prototype.update = function(dt) {
    q2 = new pc.Quat();
    q2.setFromAxisAngle(this.entity.up, mouseX);
    rb = this.entity.rigidbody;
    forward = this.entity.forward.clone();
    right = this.entity.right.clone();
    }else if({
        forward.scale(this.speed * -1);
        right.scale(this.speed * -1);
    }else if({
        temp = rb.linearVelocity;
        temp.set(0, 0, 0);
        rb.linearVelocity = temp;
        rb.teleport(0, 5, 0);
    rb.teleport(this.entity.getPosition(), q2);
Movement.prototype.onMouseMove = function(event){
    mouseX = event.x * -1;

And I honestly have no idea where I went wrong.

You don’t initialize the mouse move event in the initialize function. So this probably never worked before.

Ohh, right, thank you.

It will be glitchy for dynamic objects as teleport will remove all forces/velocity etc from the rigidbody. It isn’t recommended to use a way to move a dynamic object except for literally, teleporting.