• What is a common or efficient way to align an object to a trace.HitNormal?
    0 replies, posted
I've done this before using Expression2 of Wiremod and now I'm trying to do it with starFall (very much resembles lua). Here's a snippet of the code I'm using. hook.add("tick","runOnTickS",function() -- called every server tick                local position = self:getPos()                 local groundranger = trace.trace(             position,              self:localToWorld(Vector(0,0,-range)),              filter,              1,              1,             false         )                  local normal = self:worldToLocal(groundranger.HitNormal)         local grounded = bool_to_number(groundranger.Hit)         local hover = (H-position:getDistance(groundranger.HitPos)) * grounded         local velL = self:worldToLocal(self:getVelocity() + position)         local direction = ( position - self:localToWorld( Vector(forward-backward,right-left,up-down) + Vector(0,0,(hover*10)/10)) ) * mass * 2         local dampening = ( position - self:localToWorld( velL*Vector(0,1,grounded) ) ) * mass / 10                   local rotation = ( Vector(0,0,0) + alignToHitNormal ) * inert * 5         local friction = self:getAngleVelocity() * inert * 5                  hologram2:setPos(groundranger.HitPos)                  self:applyForceCenter( dampening - direction )         self:applyTorque( rotation - friction )       end) The variable I need to define is [alignToHitNormal] in the statement: [ local rotation = Vector(0,0,0) + alignToNormal ) * inert * 5 ] This variable is used by the statement: [ self:applyTorque ( rotation - friction ) ] Thanks for your time guys.
Sorry, you need to Log In to post a reply to this thread.