PhysicsCharacter.lua 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. require "Physics3D/PhysicsSceneEntity"
  2. class "PhysicsCharacter" (PhysicsSceneEntity)
  3. function PhysicsCharacter:PhysicsCharacter(...)
  4. if type(arg[1]) == "table" and count(arg) == 1 then
  5. if ""..arg[1]:class() == "PhysicsSceneEntity" then
  6. self.__ptr = arg[1].__ptr
  7. return
  8. end
  9. end
  10. for k,v in pairs(arg) do
  11. if type(v) == "table" then
  12. if v.__ptr ~= nil then
  13. arg[k] = v.__ptr
  14. end
  15. end
  16. end
  17. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  18. self.__ptr = Physics3D.PhysicsCharacter(unpack(arg))
  19. Polycore.__ptr_lookup[self.__ptr] = self
  20. end
  21. end
  22. function PhysicsCharacter:Update()
  23. local retVal = Physics3D.PhysicsCharacter_Update(self.__ptr)
  24. end
  25. function PhysicsCharacter:setWalkDirection(direction)
  26. local retVal = Physics3D.PhysicsCharacter_setWalkDirection(self.__ptr, direction.__ptr)
  27. end
  28. function PhysicsCharacter:jump()
  29. local retVal = Physics3D.PhysicsCharacter_jump(self.__ptr)
  30. end
  31. function PhysicsCharacter:warpCharacter(position)
  32. local retVal = Physics3D.PhysicsCharacter_warpCharacter(self.__ptr, position.__ptr)
  33. end
  34. function PhysicsCharacter:setJumpSpeed(jumpSpeed)
  35. local retVal = Physics3D.PhysicsCharacter_setJumpSpeed(self.__ptr, jumpSpeed)
  36. end
  37. function PhysicsCharacter:setFallSpeed(fallSpeed)
  38. local retVal = Physics3D.PhysicsCharacter_setFallSpeed(self.__ptr, fallSpeed)
  39. end
  40. function PhysicsCharacter:setMaxJumpHeight(maxJumpHeight)
  41. local retVal = Physics3D.PhysicsCharacter_setMaxJumpHeight(self.__ptr, maxJumpHeight)
  42. end
  43. function PhysicsCharacter:onGround()
  44. local retVal = Physics3D.PhysicsCharacter_onGround(self.__ptr)
  45. return retVal
  46. end
  47. function PhysicsCharacter:__delete()
  48. Polycore.__ptr_lookup[self.__ptr] = nil
  49. Physics3D.delete_PhysicsCharacter(self.__ptr)
  50. end