I want to be able to know how to make an unanchored object (could be a cart, or an NPC) unpushable, I mean making it so players cannot push it, however, the object itself can push the other players.
I did a quick search through google and the forum and couldn’t find information that was truly relevant, as the solutions I found were very limiting or hacky.
I barely do any physics work so my knowledge relating to constraints and stuff is almost non-existent, so I hope I get a clear answer to my problem .
If you give your object a high mass, it should be immoveable by players whilst still able to move them.
While it’s now harder to push the object, it’s still possible to push it even by a little, which is what I want to avoid completely.
I just played with adding centric velocity to the part and different physical properties but nothing seemed to solve this issue. I would maybe suggest having the objects anchored if they’re things like NPCs or Carts, as they can be moved by their root using animations or raw position/cframe editing. Other than that I’m not sure, sorry.
What do you need it for? I do assume that the best way is probably welding it and then un-welding it when it needs to be moved.
You can use :SetNetworkOwner() to change the network ownership of various entities. Remember that network ownership can not be changed for anchored BaseParts, but as you are talkiing about unanchored BaseParts it should work.
If a client comes close to an unanchored BasePart, the server will give the client network ownership over that part so the player can interact with the part physically. If you manually set the network ownership to the server, the client can not manipulate the object via physics anymore.
It’s fairly easy to script, just read through the documentation and you’ll be set.
I wish to make them be physically moved, like NPCs walking, I appreciate your help though!
As I said, I wish for NPCs that physically walk, or carts that can be moved by other objects to be unpushable by normal players. The welding method would be inefficient when the object starts moving and other players try to push it with who knows what kind of force.
This changes who owns the part, but not how it moves.
Sounds like you want kinematic rigidbody as if the object has infinite mass.
Seems like roblox’s engine is not advanced enough, unfortunate. You will need to manually script the colisions on your own.
Closest I could find was this.
You could have a part on the server which each character is NOT collideable with via collisiongroups, and then on each client, locally using a script, add a new part attached to that object which is ANCHORED, and on each frame, it is CFramed to the CFrame of that noncollidable part.
This would likely solve things for you.
The client will be unable to push the anchored part, since it is anchored, and the client can also not push the noncollidable part, since it is not collidable with them.
You don’t need to manually script the collisions, nor mess with network ownership or physics movers/mass, but it may be a little finicky to set up initially.
I used a similar system for being able to push through zombies easily in one of my games.
Hope that helps! I can explain better if you need.
What if you use an align position, align orientation, and setting the mass to a high number to achive your desired effect?
You could use an align position with rigidity enabled. And then if you want to move the block, just move the correct attachment to the correct location. You might also want to have an align orientation with rigidity enabled in the block to prevent players from spinning it.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.