Jump to content

Kerag

Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by Kerag

  1. Hi! I liked your engine. But VR player script misses all the standard features that required to build a descent VR game.
    I'm not a programmer at all. I'm a 3D designer. And I'm trying to restore that basic functionality.

    I've managed to create some sort of basic locomotion functionality. But now I'm stumbeled upon couple of things.. how to tie controller/helmet rotation to direction of movement?

    I've managed to build up a script that gives some results to move using a stick... 




        --Controller based movement
        if leftController~=nil and self.walkMethod == 1 then
            self:controllerWalk()
        end

        --Update offset position
        local pos = VR:GetOffset()
        local d = self.targetoffset:DistanceToPoint(pos)
        local speed = 0.1 * self.teleportSpeed
        if leftController~=nil and self.walkMethod~=2 then
            speed = 0.01 * self.walkSpeed
        end
        if speed>d then speed=d end
        pos = pos + (self.targetoffset - pos):Normalize() * speed
        VR:SetOffset(pos)

     

    function Script:controllerWalk()
        local playerMovement = Vec3(0)
        playerMovement.x = Math:Clamp(VR:GetControllerAxis(VR.Left, VR.TouchpadAxis).x, -1, 1)
        playerMovement.z = Math:Clamp(VR:GetControllerAxis(VR.Left, VR.TouchpadAxis).y, -1, 1)

        local controller = VR:GetControllerModel(VR.Left)
        local crot = controller:GetRotation(true)             --retrieve rotation values
        self.targetoffset = VR:GetOffset()+playerMovement*crot                    --shows that rotation values indeed are getting retrieved but movement direction in game applied in a weird way...
    end

    Im stumbeled on how to apply those values correctly so that if I hold stick up... player would move in a direction where controller is facing.
    The same goes to helmet.. I assume I have to retrieve rotation values from the camera?

     

     

     

×
×
  • Create New...