Rick Posted May 6, 2013 Share Posted May 6, 2013 Below is some code that controls my character controller. It's pulled from Aggror's tutorial and modified slightly. The problem is if I'm NOT moving I CAN'T rotate the controller. If I'm moving I can rotate the controller just fine. What am I missing? I draw to screen the self.cameraRotation.y variable and I see it changing when I move my mouse, but the controller isn't rotating without movement of the controller. function App:UpdateGame() local move = ((self.window:KeyDown(Key.W) and 1 or 0) - (self.window:KeyDown(Key.S) and 1 or 0)) * Time:GetSpeed() * 1 local strafe = ((self.window:KeyDown(Key.D)and 1 or 0) - (self.window:KeyDown(Key.A) and 1 or 0)) * Time:GetSpeed() * 1 -- get the mouse movement local currentMousePos = self.window:GetMousePosition() local mouseDifference = Vec3() mouseDifference.x = currentMousePos.x - 100 mouseDifference.y = currentMousePos.y - 100 -- adjust and set the camera rotation self.cameraRotation.y = self.cameraRotation.y + mouseDifference.x / 15 self.window:SetMousePosition(100, 100) self.player:SetInput(self.cameraRotation.y, move, strafe) end Code editing does not work very well on this site. I copy/paste and it messes it up. I go to edit and then for some reason I see tags in my code like , etc. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted May 6, 2013 Share Posted May 6, 2013 Perhaps some physic adjustment to do. Perhaps not enought physic strenght or the physic is applied to the center of the mass ? Quote Stop toying and make games Link to comment Share on other sites More sharing options...
AggrorJorn Posted May 6, 2013 Share Posted May 6, 2013 Doesn't look wrong by what I am seeing here. Could you paste the rest of the code or more parts of it. I will try it when I get home. Quote Link to comment Share on other sites More sharing options...
Rick Posted May 6, 2013 Author Share Posted May 6, 2013 This is in Lua now, but here is the entire code. You could just make a cube or something and give it a character controller physics body then save it as a prefab called player. You'll have to make a 'prefabs' folder also right off the base and the code should run as is then. I just created a little csg floor to test on. --This function will be called once when the program starts function App:Start() --Set the application title self.title = "Z Is 4 Zombie" --Create a window self.window = Window:Create(self.title) self.window:HideMouse() --Create the graphics context self.context = Context:Create(self.window, 0) if self.context == nil then return false end --Create a world self.world = World:Create() --Load a map local mapfile = System:GetProperty("map", "Maps/start.map") if Map:Load(mapfile) == false then return false end self.camera = Camera:Create() self.camera:SetFOV(70) self.playerLight = SpotLight:Create() self.playerLight:SetIntensity(3) self.cameraRotation = Vec3() self.player = Prefab:Load("Prefabs/player.pfb") self.moveSpeed = 3 self:CameraFollow() return true end function App:CameraFollow() -- over the shoulder view self.camera:SetPosition(self.player:GetPosition()) self.camera:SetRotation(self.player:GetRotation()) self.camera:Move(.75, 1.8, -1) self.camera:Turn(0, -5, 0) local camY = self.camera:GetRotation().y self.camera:SetRotation(self.cameraRotation.x, camY, 0) -- a light so the player model stands out self.playerLight:SetPosition(self.player:GetPosition()) self.playerLight:SetRotation(self.player:GetRotation()) self.playerLight:Move(3.75, .75, 0) self.playerLight:Turn(0, -90, 0) end function App:UpdateGame() local move = ((self.window:KeyDown(Key.W) and 1 or 0) - (self.window:KeyDown(Key.S) and 1 or 0)) * Time:GetSpeed() * self.moveSpeed local strafe = ((self.window:KeyDown(Key.D)and 1 or 0) - (self.window:KeyDown(Key.A) and 1 or 0)) * Time:GetSpeed() * (self.moveSpeed * .66) -- get the mouse movement local currentMousePos = self.window:GetMousePosition() local mouseDifference = Vec3() mouseDifference.x = currentMousePos.x - 100 mouseDifference.y = currentMousePos.y - 100 -- adjust and set the camera rotation local tempX = self.cameraRotation.x + (mouseDifference.y / 15) if tempX > -25 and tempX < 25 then self.cameraRotation.x = tempX end self.cameraRotation.y = self.cameraRotation.y + mouseDifference.x / 15 self.window:SetMousePosition(100, 100) self.player:SetInput(self.cameraRotation.y, move, strafe) end --This is our main program loop and will be called continuously until the program ends function App:Loop() --If window has been closed, end the program if self.window:Closed() or self.window:KeyDown(Key.Escape) then return false end --Update the app timing Time:Update() --Update the world self.world:Update() self:UpdateGame() self:CameraFollow() --Render the world self.world:Render() self.context:SetBlendMode(Blend.Alpha) self.context:DrawText("Cam Rotation Y:"..self.cameraRotation.y, 0, 0) -- draw crosshairs self.context:SetColor(1, 0, 0, 1) self.context:DrawLine(self.context:GetWidth() / 2, (self.context:GetHeight() / 2) - 15, self.context:GetWidth() / 2, (self.context:GetHeight() / 2) + 15) self.context:DrawLine((self.context:GetWidth() / 2) - 15, self.context:GetHeight() / 2, (self.context:GetWidth() / 2) + 15, self.context:GetHeight() / 2) self.context:SetColor(0, 0, 0, 1) self.context:SetBlendMode(Blend.Solid) --Refresh the screen self.context:Sync() --Returning true tells the main program to keep looping return true end Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted May 6, 2013 Share Posted May 6, 2013 After trying myself, I can only come to the conclusion that this is a bug. I have also tried this by creating a player character controller by hand instead of loading a prefab. The result is the samen Quote Link to comment Share on other sites More sharing options...
Jim Posted May 6, 2013 Share Posted May 6, 2013 Hi Rick It works for me as I can tell. I move the mouse and the cube rotates to different direction Quote Link to comment Share on other sites More sharing options...
Jim Posted May 7, 2013 Share Posted May 7, 2013 On a second check after I add more blocks to like wall to the scene it has a big lag. There appears to be some problem with the controller. Quote Link to comment Share on other sites More sharing options...
PerEspen00 Posted May 7, 2017 Share Posted May 7, 2017 This was a long time ago. But I'm having the same issue now,. I worked around it by adding a Math:Random(-0.00001, 0.00001) to one of the movement parameters, this causes it to work. This should probarly get fixed though. Quote Link to comment Share on other sites More sharing options...
macklebee Posted May 7, 2017 Share Posted May 7, 2017 This was a long time ago. But I'm having the same issue now,. I worked around it by adding a Math:Random(-0.00001, 0.00001) to one of the movement parameters, this causes it to work. This should probarly get fixed though. This is not occurring for me at all. So instead of necro-posting a 4 year old post, make a new post with an example that shows your problem. Add details like if you are using the beta or an older revision, are you using a custom script that controls the controller, etc... Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Thirsty Panther Posted May 13, 2017 Share Posted May 13, 2017 I believe this was a problem some time ago but was fixed with an update. Is your project up to date? Quote Link to comment Share on other sites More sharing options...
PerEspen00 Posted May 13, 2017 Share Posted May 13, 2017 Yep. I'll have a look at it and then make a post. Quote Link to comment Share on other sites More sharing options...
martyj Posted May 13, 2017 Share Posted May 13, 2017 I have a bug report on this. http://www.leadwerks.com/werkspace/topic/15587-enttiysetinput-doesnt-rotate-without-movment/ Original Bug Report http://www.leadwerks.com/werkspace/topic/15442-setinput/ Here is how I solve it. if (camMovementZ == 0 && camMovementX == 0) { camMovementZ = 0.001; // Not 0 but not enough to see camMovementX = 0.001; // Not 0 but not enough to see } this->playerModel->SetInput(cameraRotationY, camMovementZ, camMovementX); Quote Link to comment Share on other sites More sharing options...
macklebee Posted May 13, 2017 Share Posted May 13, 2017 Here is how I solve it. or just update your project to three of the available versions, beta (Ver4.4), stable (Ver4.3), or Ver4.1. This latest issue was caused by an "optimization" in the Ver4.2 that was resolved within Ver4.3 beta and was never part of the Ver4.3 stable release. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Jazz Posted May 13, 2017 Share Posted May 13, 2017 or just update your project to any of the available versions, beta (Ver4.4), stable (Ver4.3), or Ver4.1. This latest issue was caused by an "optimization" in the Ver4.2 that was resolved within a week or two and was never part of the Ver4.3 stable release. This does occur in the latest (4.4) beta. The attached map should show this if you run it and don't move the player. 04-Moving Platforms.rar Quote --- Scott Using Windows 7 Ultimate 64 bit/Core I7-2700K @ 4312mhz/24G RAM/Nvidia GTX 1060 Link to comment Share on other sites More sharing options...
macklebee Posted May 13, 2017 Share Posted May 13, 2017 Yeah, not quite sure what i should be seeing here in the beta. I can turn completely around with just the mouse while not pressing the WSAD keys. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
gamecreator Posted May 13, 2017 Share Posted May 13, 2017 Release Professional doesn't have this issue. You can rotate while move=0. Quote Link to comment Share on other sites More sharing options...
Jazz Posted May 13, 2017 Share Posted May 13, 2017 Yeah, not quite sure what i should be seeing here in the beta. I can turn completely around with just the mouse while not pressing the WSAD keys. What happens if you run it and don't move the mouse either? Quote --- Scott Using Windows 7 Ultimate 64 bit/Core I7-2700K @ 4312mhz/24G RAM/Nvidia GTX 1060 Link to comment Share on other sites More sharing options...
macklebee Posted May 13, 2017 Share Posted May 13, 2017 What happens if you run it and don't move the mouse either? huh? am i missing something? why wouldn't it not rotate if i don't move the mouse? Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Jazz Posted May 13, 2017 Share Posted May 13, 2017 huh? am i missing something? why wouldn't it not rotate if i don't move the mouse? Maybe I missed something. I'm talking about the character falling through the platform. Quote --- Scott Using Windows 7 Ultimate 64 bit/Core I7-2700K @ 4312mhz/24G RAM/Nvidia GTX 1060 Link to comment Share on other sites More sharing options...
macklebee Posted May 13, 2017 Share Posted May 13, 2017 Maybe I missed something. I'm talking about the character falling through the platform. yeah- this post was about the character controller not rotating unless the controller was moving... because someone wasn't using an up to date version. The problem you are referring to is a completely different issue. And yes, i do see that... but it only occurs on the start of the program - almost like the character physics werent created all the way yet prior to the platform moving. if you jump several times, you can get the character to land on top of the platform and its all okay after that. Definitely an issue, but as Josh is implementing the new newton physics engine version in a new way in this beta i suspect there will be issues. You should definitely make a bug report. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Recommended Posts
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.