Jump to content

character rotation issue


Rick
 Share

Recommended Posts

I'm using YouGrooves little armored guy. Originally the Y rotation right out of the box has it at 180. I opened the source fbx in UU3D and rotated it so now it reads 0. I have the very basic 3rd person script below and what I find odd is when I'm not moving the character is looking away from the camera (as the camera offsets up and back from the character). When I move though the character turns and is facing the camera the entire time I'm moving. Why would this be? How can I fix this?

 

In Script:Movement() at the end I rotate the character (this script is attached to the character model) 180 around Y because otherwise he's always facing the camera no matter what).

 

import "Scripts/AnimationManager.lua"

Script.Camera = nil --entity


function Script:Start()
self.playerMovement = Vec3(0,0,0)
self.cameraYaw = 0
self.cameraPitch = 10

local test = self.entity:GetRotation().y

self.moveSpeed = 5

self.cameraBone = self.entity:FindChild("Bone_020")
self.upperBody = self.entity:FindChild("Bone_010")

-- 2 "layers" of animations. the base layer and the upper body layer
self.baseAnimMgr = AnimationManager:Create(self.entity)
self.upperAnimMgr = AnimationManager:Create(self.upperBody)
end

function Script:UpdateWorld()
-- put "thinking" logic here
end

function Script:Movement()
-- handle player movement
self.playerMovement.z = ((App.window:KeyDown(Key.W) and 1 or 0) - (App.window:KeyDown(Key.S)and 1 or 0)) * Time:GetSpeed() * self.moveSpeed
self.playerMovement.x = ((App.window:KeyDown(Key.D) and 1 or 0) - (App.window:KeyDown(Key.A)and 1 or 0)) * Time:GetSpeed() * self.moveSpeed

-- move the camera to the player and set the yaw from 3rd person view
self.Camera:SetPosition(self.entity:GetPosition(true))
self.Camera:SetRotation(Vec3(0, self.cameraYaw, 0))

-- offset the camera up and back
self.Camera:Move(0, 3, -3)

-- set the rotation of the camera for the pitch
self.Camera:SetRotation(Vec3(self.cameraPitch, 0, 0))

self.entity:SetInput(self.cameraYaw, self.playerMovement.z, self.playerMovement.x, 0, false, 1)

self.entity:SetRotation(Vec3(0, 180, 0), true)
end

function Script:Animaitons()
-- what animation should we be playing
self.baseAnimMgr:SetAnimationSequence(2, 0.02)
end

function Script:UpdatePhysics()
self:Movement()

self:Animaitons()
end

function Script:Draw()
-- the order we put these in matters!
self.baseAnimMgr:Update()

self.upperAnimMgr:Update()
end

function Script:PostRender(context)

end

function Script:Delete()

end

Link to comment
Share on other sites

I got it working by selecting all in UU3D. Then rotating the scene by 180. When you open up the model viewer the character should be facing away from you. I also noticed that if you place your original character in the scene and look at the rotation it says 180. Now after doing the UU3D thing it says 0, which is right.

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...