Garry's Mod Wiki

Revision Difference

PhysObj:ComputeShadowControl#510910

<function name="ComputeShadowControl" parent="PhysObj" type="classfunc">⤶ <description>Allows you to move a PhysObj to a point and angle in 3D space.</description>⤶ <realm>Shared</realm>⤶ <args>⤶ <arg name="shadowparams" type="table">The parameters for the shadow. See example code to see how its used.</arg>⤶ </args>⤶ </function>⤶ ⤶ <example>⤶ <description>Move a PhysObj to vector 0 0 0 with angles 0 0 0.</description>⤶ <code>⤶ function ENT:Initialize()⤶ ⤶ self:StartMotionController()⤶ self.ShadowParams = {}⤶ ⤶ end⤶ function ENT:PhysicsSimulate( phys, deltatime )⤶ ⤶ phys:Wake()⤶ ⤶ self.ShadowParams.secondstoarrive = 1 // How long it takes to move to pos and rotate accordingly - only if it could move as fast as it want - damping and max speed/angular will make this invalid (Cannot be 0! Will give errors if you do)⤶ self.ShadowParams.pos = Vector( 0, 0, 0 ) // Where you want to move to⤶ self.ShadowParams.angle = Angle( 0, 0, 0 ) // Angle you want to move to⤶ self.ShadowParams.maxangular = 5000 //What should be the maximal angular force applied⤶ self.ShadowParams.maxangulardamp = 10000 // At which force/speed should it start damping the rotation⤶ self.ShadowParams.maxspeed = 1000000 // Maximal linear force applied⤶ self.ShadowParams.maxspeeddamp = 10000// Maximal linear force/speed before damping⤶ self.ShadowParams.dampfactor = 0.8 // The percentage it should damp the linear/angular force if it reaches it's max amount⤶ self.ShadowParams.teleportdistance = 200 // If it's further away than this it'll teleport (Set to 0 to not teleport)⤶ self.ShadowParams.deltatime = deltatime // The deltatime it should use - just use the PhysicsSimulate one⤶ ⤶ phys:ComputeShadowControl(self.ShadowParams)⤶ ⤶ end⤶ </code>⤶ ⤶ </example>