Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About QuantumPixel

  • Rank
  • Birthday 09/13/1977

Profile Information

  • Gender
  • Location
    Alabama, USA, Earth

Recent Profile Visitors

670 profile views
  1. Hello again, Once more, I'm having some issues with the collision system. I have an object in my game that I want to have bouncing back and forth between the map walls that will act as an obstacle for the player character. I cannot use a physics object for this, as it makes the object's behavior inconsistent and difficult to control after its first collision. However, with its Mass set to 0, it no longer registers collisions with the map walls. It will collide with a player character (which is a physics object) and react as it is supposed to, just not with the walls or any other non-physics object placed in the scene. What can I do to correct this and have it register collisions with non-physics objects? Thanks! I don't think it is helpful, but I have included the object's settings and script below, just in case. Settings: Physics Mode: Rigid Body Collision Type: Character (I have tried every available type and none of them solve this issue.) Mass: 0 Character Angle: 0 Swept Collision: False Nav Obstacle: False Script.moveSpeed = 5.0 --float "Movement Speed" Script.initDir = -90 --float "Initial Direction" function Script:Start() self.entity:SetRotation(0, self.initDir, 0, true) self.entity:SetMass(0) dirFlip = 1 end function Script:UpdateWorld() self.entity:Move(0, 0, self.moveSpeed * dirFlip, false) end function Script:Collision(entity, position, normal, speed) dirFlip = dirFlip * -1 end
  2. I thank you for your reply, Genebris and Josh. It helped.
  3. Hello. I am super new to Leadwerks, Lua script, and OOP languages in general. I am just trying to put together a simple game where the player can move a character around a room and dodge a bouncing ball-of-death; but the collisions are giving me a hard time. At this point, the script attached to my player character model simply contains the following code: Script.moveRate = 0.05 --float "Movement Rate" function Script:UpdatePhysics() if window:KeyDown(Key.W) then self.entity:Translate(0, 0, self.moveRate) end if window:KeyDown(Key.S) then self.entity:Translate(0, 0, -self.moveRate) end if window:KeyDown(Key.A) then self.entity:Translate(-self.moveRate, 0, 0) end if window:KeyDown(Key.D) then self.entity:Translate(self.moveRate, 0, 0) end end I have tried using Leadwerk's built-in physics to handle collisions, but they yield unwanted results. If the Physics Mode is set to Rigid Body, then the character model gets knocked over upon making contact with a wall brush; and if the Physics mode is set to Character Physics, the model sinks halfway into the floor brush and bounces when it collides with a wall, sometimes being launched away from the wall when the button is released. I have tried various setting combinations of Physics Mode and Physics Types, but none have yielded better results. In light of this, I thought I might try writing my own code to handle the collision behavior, but I can't seem to find any commands in the API reference that deal with collisions, aside from the CollisionHook command, which I am completely baffled by. (I have no idea what a "hook" is, and there is no example code given.) Apparently, I am missing something, somewhere. Can anyone point me in the right direction? Thanks!
  4. Adding "self.entity:SetPhysicsMode(Entity.CharacterPhysics)" fixed it. Thanks!
  5. Your suggestions did fix the problem that I was having. Unfortunately, it also created new issues. Now my player entity has physics being applied to it, so it falls over and goes bouncing across the terrain if it hits a rock or uneven ground. It looks like I'm going to have to approach this from a different angle. But thanks anyway, guys. I appreciate the help.
  6. Greetings all, I am very new to using the Leadwerks engine and I am having trouble getting my player entity to move across the terrain I've created. The FPSPlayer.lua script works in this regard, but it was not compatible with what I needed for this project, so I had to write my own character controller script. Everything I've tried results in either the player entity falling through the terrain upon start or moving along the origin plane and passing through the terrain instead of climbing/colliding with it. I have dug through the FPSPlayer.lua script trying to find where this functionality was implemented, but I am unable to find it. Any help would be greatly appreciated. Here is my script" Script.moveSpeed = 4.0 --float "Movement Speed" Script.mouseTurn = 6.0 --float "Mouse Rotation Speed" function Script:Start() -- Create Camera self.camera = Camera:Create() self.pivot = Pivot:Create() self.camera:SetParent(self.pivot) self.camera:Move(0, 2, -2) self.camera:SetRotation(25, 0, 0) self.entity:SetKeyValue("type","player") end -- Adjust the camera orientation relative to the player function Script:UpdateCamera() self.pivot:SetPosition(self.entity:GetPosition()) self.pivot:SetRotation(self.pivot:GetRotation().x, self.pivot:GetRotation().y, 0) end function Script:UpdateWorld() local MoveX = 0 local MoveZ = 0 if window:KeyDown(Key.W) then self.entity:SetRotation(0, self.pivot:GetRotation().y, 0) MoveZ = MoveZ + 1 end if window:KeyDown(Key.S) then self.entity:SetRotation(0, self.pivot:GetRotation().y, 0) MoveZ = MoveZ - 1 end if window:KeyDown(Key.D) then MoveX = MoveX + 1 end if window:KeyDown(Key.A) then MoveX = MoveX - 1 end self.entity:Move(MoveX * self.moveSpeed / 2, 0, MoveZ * self.moveSpeed, false) if window:MouseDown(2) then if window:GetMousePosition().x > self.lastMouseX then self.pivot:Turn(0, self.mouseTurn, 0) end if window:GetMousePosition().x < self.lastMouseX then self.pivot:Turn(0, -self.mouseTurn, 0) end if window:GetMousePosition().y > self.lastMouseY then self.pivot:Turn(self.mouseTurn / 2, 0 ,0) end if window:GetMousePosition().y < self.lastMouseY then self.pivot:Turn(-self.mouseTurn / 2, 0, 0) end window:SetMousePosition(context:GetWidth() / 2, context:GetHeight() / 2) end self.lastMouseX = window:GetMousePosition().x self.lastMouseY = window:GetMousePosition().y -- Update The Camera Each Loop self:UpdateCamera() end
  • Create New...