Movement and rotation troubles in VR?
So I have been making my first VR game and I want to be able to move in game
I have the grab script hands head etc
but I just cant work out how to move using the thumbpad(htc vive) or the trigger on the controller in the direction your facing
I also need a rotation script
Here are my scripts
03 | workspace.ThingsHappen.MoveMe:FireServer() |
05 | workspace.CurrentCamera.CameraType = "Scriptable" |
07 | workspace.CurrentCamera.CFrame = CFrame.new() |
09 | local VRService = game:GetService( "VRService" ) |
10 | local InputService = game:GetService( "UserInputService" ) |
12 | VRService.UserCFrameChanged:Connect( function () |
13 | local LeftHand = VRService:GetUserCFrame(Enum.UserCFrame.LeftHand) |
14 | local RightHand = VRService:GetUserCFrame(Enum.UserCFrame.RightHand) |
15 | local Head = VRService:GetUserCFrame(Enum.UserCFrame.Head) |
16 | workspace.ThingsHappen.STUFF 2 Happen:FireServer(RightHand,LeftHand,Head) |
19 | InputService.InputBegan:Connect( function (Type, Stuff) |
20 | if Type.KeyCode = = Enum.KeyCode.ButtonR 1 then |
21 | workspace.ThingsHappen.RightGrip:FireServer() |
22 | elseif Type.KeyCode = = Enum.KeyCode.ButtonL 1 then |
23 | workspace.ThingsHappen.LeftGrip:FireServer() |
27 | InputService.InputEnded:Connect( function (Type, Stuff) |
28 | if Type.KeyCode = = Enum.KeyCode.ButtonR 1 then |
29 | workspace.ThingsHappen.RightGo:FireServer() |
30 | elseif Type.KeyCode = = Enum.KeyCode.ButtonL 1 then |
31 | workspace.ThingsHappen.LeftGo:FireServer() |
server script
01 | function ItsHim(player, RightHand, LeftHand, Head) |
02 | workspace.Johna.CFrame = (RightHand) |
03 | workspace.Jenna.CFrame = (LeftHand) |
07 | if workspace:FindFirstChild( "GrippedRight" ) ~ = nil then |
08 | workspace.GrippedRight.AlignOrientation.Attachment 1 = nil |
09 | workspace.GrippedRight.AlignPosition.Attachment 1 = nil |
10 | workspace.GrippedRight.Parent = workspace.ThingsInHere |
14 | function GripGrabRight() |
15 | local TheKids = workspace.ThingsInHere:GetChildren() |
16 | local DistanceRight = 1 |
18 | if (TheKids [ i ] .Attachment.WorldPosition - workspace.Johna.Position).magnitude<DistanceRight and TheKids [ i ] .AlignOrientation.Attachment 1 = = nil then |
20 | DistanceRight = (TheKids [ i ] .Attachment.WorldPosition - workspace.Johna.Position).magnitude |
21 | TheKids [ i ] .AlignOrientation.Attachment 1 = workspace.Johna.Attachment |
22 | TheKids [ i ] .AlignPosition.Attachment 1 = workspace.Johna.Attachment |
23 | TheKids [ i ] .Name = "GrippedRight" |
24 | TheKids [ i ] .Parent = workspace |
30 | if workspace:FindFirstChild( "GrippedLeft" ) ~ = nil then |
31 | workspace.GrippedLeft.AlignOrientation.Attachment 1 = nil |
32 | workspace.GrippedLeft.AlignPosition.Attachment 1 = nil |
33 | workspace.GrippedLeft.Parent = workspace.ThingsInHere |
37 | function GripGrabLeft() |
38 | local TheKids = workspace.ThingsInHere:GetChildren() |
39 | local DistanceLeft = 1 |
41 | if (TheKids [ i ] .Attachment.WorldPosition - workspace.Jenna.Position).magnitude<DistanceLeft and TheKids [ i ] .AlignOrientation.Attachment 1 = = nil then |
43 | DistanceLeft = (TheKids [ i ] .Attachment.WorldPosition - workspace.Jenna.Position).magnitude |
44 | TheKids [ i ] .AlignOrientation.Attachment 1 = workspace.Jenna.Attachment |
45 | TheKids [ i ] .AlignPosition.Attachment 1 = workspace.Jenna.Attachment |
46 | TheKids [ i ] .Name = "GrippedLeft" |
47 | TheKids [ i ] .Parent = workspace |
52 | function MoveThem(player) |
53 | player.Character.HumanoidRootPart.CFrame = CFrame.new(Vector 3. new( 0 , 1000 , 0 )) |
54 | player.Character.HumanoidRootPart.Anchored = true |
57 | script.STUFF 2 Happen.OnServerEvent:Connect(ItsHim) |
58 | script.RightGrip.OnServerEvent:Connect(GripGrabRight) |
59 | script.RightGo.OnServerEvent:Connect(GripGoRight) |
60 | script.LeftGrip.OnServerEvent:Connect(GripGrabLeft) |
61 | script.LeftGo.OnServerEvent:Connect(GripGoLeft) |
63 | script.MoveMe.OnServerEvent:Connect(MoveThem) |