Jump to content

hom.png

Members
  • Posts

    3
  • Joined

  • Last visited

Posts posted by hom.png

  1. 12 hours ago, Slastraf said:

    So you are only setting the y rotation of lets say your character controller.
    Why would you not just rotate it based on direction vector and make it really small ?

    local rotVec = window:GetMousePosition()x-(window:GetWidth*0.5)

    local lookSpeedMultiplier = 0.01

    self.entity:GetRotation(0, self.entity.rotation.y + (rotVec * lookSpeedMultiplier), 0) 

     

    I just wrote the code in here so there might be errors but it may work. Also always make *0.5 instead of /2 because the compiler could not detect that /2 is more difficult to calculate than *0.5

    I don't think this is the right thing because I want it to rotate towards the mouse yet this will rotate it constantly however, there is some good use in this as if I make a rotVec for the y coordinates as well and do the whole Rot=ATan(rotVecy/rotVecx) thing and then do self.entity:SetRotation(0,self.entity:GetRotation().y+(Rot*lookSpeedMultiplier),0) and then run the code you can see that the moment you cross where x=0 the entity starts rotating the other way and I assume this is the base of the issue.

  2. so I try to get the center of the screen and find the mouse position and then find the difference then using ATan(change in y/ change in x) to find the angle the object must rotate to and set the angle to that, the only issue is when the mouse x is <= 0 the object flips (so lets say the right side of the object was facing the mouse it then becomes the left side) I assume this issue is to do with the fact that ATan(change in y/change in x)=ATan(-change in y/-change in x) but here is my code:

    image.png.bf1f6409a5a96aeb71aec545bb9064cc.png

     

×
×
  • Create New...