[SOLVED] How to change rigidbody type with key press

I need help on making a block that im looking at making it static
(with a keyboard key)
anything i could do to make a block back to static with a keyboard input?

the block is dynamic and i look at it and i input a certain key to make it to static to stay and i could switch it back to dynamic with a keyboard key input
and i want to use a tag so then you could use different types of blocks i want to make static or dynamic

help i almost got what i want
so i got it but i want to keep on changing it to static into dynamic
help? please?

I cannot say I understand at all what you are asking here for?

keyboard input that would put the block as static and if you press it again then it puts it as dynamic with a keyboard input like “F”

You should be able to do this via the rigidbody component and changing the type: https://developer.playcanvas.com/api/pc.RigidBodyComponent.html#type

e.g entity.rigidbody.type = pc.BODYTYPE_STATIC

OMG okay thanks
but how do you make it repeat so then i could change it as many times as i want

You change it back and forth. I’m not sure exactly what you are asking here.

like lets say i have to make it dynamic but then i want it to be static
but then i want it dynamic i press the same key to do so
this is the code im using but it doesnt work

var Box = pc.createScript('box');

// initialize code called once per entity
Box.prototype.initialize = function() {
    
};

// update code called every frame
Box.prototype.update = function(dt) {
    if (this.app.keyboard.wasPressed(pc.KEY_F)) {
        this.entity.rigidbody.type = pc.BODYTYPE_DYNAMIC;
    }
      
    
Box.prototype.update = function(dt) {
    if (this.app.keyboard.wasPressed(pc.KEY_C)) {
        this.entity.rigidbody.type = pc.BODYTYPE_STATIC;
    }

};
};

// swap method called for script hot-reloading
// inherit your script state here
// Box.prototype.swap = function(old) { };

okay nvm i actually got it omg