• Magnets
    3 replies, posted
how would i go about making an entity attract other entities? i can't find any documentation on the gmod wiki.
Use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/PhysObj/ApplyForceCenter]PhysObj:ApplyForceCenter[/url] towards your magnet entity. At the same time apply an opposite force of the same strength to your entity, because for every action, there is an equal and opposite reaction.
[url]https://developer.valvesoftware.com/wiki/Phys_magnet[/url] Otherwise you can calculate the direction of force towards the magnet as ( object_to_pull:GetPos() - magnet:GetPos() ):GetNormalized() * PullForceInUnits and use SetVelocity or ApplyForceCenter. The standard HL2 magnet works pretty good though for smaller tasks, I used it for a pulley/crane system for a helicopter.
alright, thanks for the help, i think this is what i was looking for.
Sorry, you need to Log In to post a reply to this thread.