Jump to content

How to fix character rotation


Slastraf
 Share

Recommended Posts

Hello

I have a character model childed to a pivot with character physics, and I use SetInput() to move the character forward depending on how the rotation of the char model is. Their position is at the exact same place so it should actually work similar to the fps script, but it doesn't work so good. Take a look at the following video that demonstrates what is happening:I think its a small math problem, but here is the part of the script that controls it:

	self.entity:SetInput((self.character:GetRotation().y-90), playerMovement.z, playerMovement.x, jump , false, 1.0, 0.5, false, 50)
	-- note that the "-90" exists because the playermodel needs this offset to look forward
	if window:KeyDown(Key.Q) then self:addRotationOnY(-2) end
	if window:KeyDown(Key.E) then self:addRotationOnY(2) end
--=================================
function Script:addRotationOnY(params)
	local currRot = self.character:GetRotation()
	self.character:SetRotation(0, currRot.y + params, 0)
end

EDIT:

this fixed it:

	local addRotation = 0
	if window:KeyDown(Key.Q) then addRotation = -self.rotationSpeed end
	if window:KeyDown(Key.E) then addRotation = self.rotationSpeed end

	self.entity:SetInput((self.entity:GetRotation().y+addRotation), playerMovement.z, playerMovement.x, jump , false , 1.0, 0.5, true, 50)

It is a workaround because one cant change an entities rotation if it uses SetInput with SetRotation()

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...