Isosta
|
  |
| Joined: 10 May 2015 |
| Total Posts: 14729 |
|
|
| 17 Jun 2016 08:26 PM |
What is the best method of detecting someone has started wallrunning and keeping them there?
https://www.youtube.com/watch?v=D4CxeTu6HuU
this is how i did my wallrun the last time (This is not the current weapon system)
And i didn't really "pull" you to the wall if you know what i mean. It raycasted on the right and left sides of the torso and detected parts named wallrun. I'd like to make it so once you've connected you can make full rotations on it and the camera angle will adjust based on what angle you are on the wall. So if you're facing away from the wall, the camera will be 0 degrees. If you're at a 90 degree angle with the left facing the wall, it will be at an angle of -20 degrees. Right side, 20 degrees. Best way to detect the angle between the wall and the where the player is looking. like this:
prntscr/bhrmcr
Red dot being the player, dotted line being where they're looking, and X being the angle.
#code io.write('( ͡° ͜ʖ ͡°)') |
|
|
| Report Abuse |
|
|
ElectroTM
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 1135 |
|
|
| 17 Jun 2016 08:40 PM |
a debounce...?
y-you too... |
|
|
| Report Abuse |
|
|
Isosta
|
  |
| Joined: 10 May 2015 |
| Total Posts: 14729 |
|
|
| 17 Jun 2016 08:42 PM |
excuse me?
#code io.write('( ͡° ͜ʖ ͡°)') |
|
|
| Report Abuse |
|
|
Isosta
|
  |
| Joined: 10 May 2015 |
| Total Posts: 14729 |
|
|
| 17 Jun 2016 08:59 PM |
all ur posts are being blocked.
#code io.write('( ͡° ͜ʖ ͡°)') |
|
|
| Report Abuse |
|
|
ElectroTM
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 1135 |
|
|
| 17 Jun 2016 09:00 PM |
are you seeing them? I know they're being blocked but I've spent the past 10 mins trying to say something that isn't blocked.
y-you too... |
|
|
| Report Abuse |
|
|
Isosta
|
  |
| Joined: 10 May 2015 |
| Total Posts: 14729 |
|
|
| 17 Jun 2016 09:00 PM |
It just says most recent poster ElectroTM and makes it green again.
#code io.write('( ͡° ͜ʖ ͡°)') |
|
|
| Report Abuse |
|
|
ElectroTM
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 1135 |
|
|
| 17 Jun 2016 09:03 PM |
Jesus, I'm so done today. basically I'm saying use the dot product.
y-you too... |
|
|
| Report Abuse |
|
|
Isosta
|
  |
| Joined: 10 May 2015 |
| Total Posts: 14729 |
|
|
| 17 Jun 2016 09:12 PM |
I'm not familiar with the dot product.
I have a part, which is the wall, and the Torso.
How do I get the degree between the two using the dot product?
#code io.write('( ͡° ͜ʖ ͡°)') |
|
|
| Report Abuse |
|
|
ElectroTM
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 1135 |
|
|
| 17 Jun 2016 09:18 PM |
you get the lookvector of the camera or whatever you want to compare the angles of (In this case, probably your torso) and you get the lookvector of the wall, or you can create a part with the same position as the wall faced in the direction you're moving. That way you can get the lookvector of the wall in the direction you're running. then I think it's just lookvector1:Dot(lookvector2)
y-you too... |
|
|
| Report Abuse |
|
|
Isosta
|
  |
| Joined: 10 May 2015 |
| Total Posts: 14729 |
|
|
| 17 Jun 2016 09:35 PM |
https://www.roblox.com/games/435838411/Camera-Angle-math-stuff
okay, so i get the effect I want using this: (You can test it above)
while game:GetService('RunService').RenderStepped:wait() do local dot = char.Torso.CFrame.lookVector:Dot(game.Workspace.Wallrun.CFrame.lookVector)*90 game.Workspace.CurrentCamera.CFrame = game.Workspace.CurrentCamera.CFrame * CFrame.Angles(0,0,math.rad(dot/5)) end
but if you switch sides on the part, you get the opposite effect. And on the edges, the effect is nothing when an arm is facing the wall, and tilted when facing the wall or away from the wall. What is the best way to fix this?
#code io.write('( ͡° ͜ʖ ͡°)') |
|
|
| Report Abuse |
|
|
EgoMoose
|
  |
| Joined: 04 Feb 2009 |
| Total Posts: 2896 |
|
|
| 17 Jun 2016 10:13 PM |
Hmm, you could try converting the points to a 2D plane then using arc tangent, but you'd need the surface normal of the part you're wall running on. You'd also need to assume a "wall run" would never happen when the player can just normally walk on the surface (which they shouldn't need to).
local player = game:GetService("Players").LocalPlayer; local character = player.CharacterAdded:wait(); local camera = game:GetService("Workspace").CurrentCamera;
local hrp = character:WaitForChild("HumanoidRootPart"); local probe = 1.5;
function update() -- blah blah blah... raycast stuff local p = hrp.CFrame.p; local left = Ray.new(p, hrp.CFrame:vectorToWorldSpace(Vector3.new(-probe, 0, 0))); local right = Ray.new(p, hrp.CFrame:vectorToWorldSpace(Vector3.new(probe, 0, 0))); local lhit, lpos, lnormal = game:GetService("Workspace"):FindPartOnRay(left, character); local rhit, rpos, rnormal = game:GetService("Workspace"):FindPartOnRay(right, character); local accept = {}; for _, set in next, {{lhit, lpos, lnormal}, {rhit, rpos, rnormal}} do if set[1] and set[1].Name == "Wallrun" then table.insert(accept, set); end; end; table.sort(accept, function(a, b) return (a[2] - p).magnitude < (b[2] - p).magnitude; end); -- this is what matters if accept[1] then local wall, pos, normal = accept[1][1], accept[1][2], accept[1][3]; local otherVector = normal:Cross(Vector3.new(0, 1, 0)); -- as I said Vector3.new(0, 1, 0) should never be a wall run normal anyway b/c u can walk on it -- getting the angle relative to the camera local lv = camera.CFrame.lookVector; local x, y = lv:Dot(normal), lv:Dot(otherVector); -- projection onto 2D plane local angle = math.atan2(x, y); -- plus or minus a pi err whatever... print(math.deg(angle)); -- try urself end; end;
game:GetService("RunService").RenderStepped:connect(update);
|
|
|
| Report Abuse |
|
|
Isosta
|
  |
| Joined: 10 May 2015 |
| Total Posts: 14729 |
|
|
| 17 Jun 2016 10:25 PM |
I did this and the right side works fine, but the objective was to get them so i could easily switch beween right and left without disconnecting from the wall, so a right and left ray wouldn't work. As for the left, side...
well,
https://www.roblox.com/games/435838411/Camera-Angle-math-stuff#!/game-instances
local player = game:GetService("Players").LocalPlayer; local character = player.Character or player.CharacterAdded:wait(); local camera = game:GetService("Workspace").CurrentCamera;
local hrp = character:WaitForChild("HumanoidRootPart"); local probe = 1.5;
function update() -- blah blah blah... raycast stuff local p = hrp.CFrame.p; local left = Ray.new(p, hrp.CFrame:vectorToWorldSpace(Vector3.new(-probe, 0, 0))); local right = Ray.new(p, hrp.CFrame:vectorToWorldSpace(Vector3.new(probe, 0, 0))); local lhit, lpos, lnormal = game:GetService("Workspace"):FindPartOnRay(left, character); local rhit, rpos, rnormal = game:GetService("Workspace"):FindPartOnRay(right, character); local accept = {}; for _, set in next, {{lhit, lpos, lnormal}, {rhit, rpos, rnormal}} do if set[1] and set[1].Name == "Wallrun" then table.insert(accept, set); end; end; table.sort(accept, function(a, b) return (a[2] - p).magnitude < (b[2] - p).magnitude; end); -- this is what matters if accept[1] then local wall, pos, normal = accept[1][1], accept[1][2], accept[1][3]; local otherVector = normal:Cross(Vector3.new(0, 1, 0)); -- as I said Vector3.new(0, 1, 0) should never be a wall run normal anyway b/c u can walk on it -- getting the angle relative to the camera local lv = camera.CFrame.lookVector; local x, y = lv:Dot(normal), lv:Dot(otherVector); -- projection onto 2D plane local angle = math.atan2(x, y); -- plus or minus a pi err whatever... print(math.deg(angle)); -- try urself game.Workspace.CurrentCamera.CFrame = game.Workspace.CurrentCamera.CFrame * CFrame.Angles(0,0,math.rad((90-math.deg(angle))/5)) end; end;
game:GetService("RunService").RenderStepped:connect(update);
#code io.write('( ͡° ͜ʖ ͡°)') |
|
|
| Report Abuse |
|
|
EgoMoose
|
  |
| Joined: 04 Feb 2009 |
| Total Posts: 2896 |
|
|
| 17 Jun 2016 10:27 PM |
| Yes my response was regarding the angle so that you could properly adjust the camera tilt. It has nothing to do with switching between walls. The code I provided was an example. |
|
|
| Report Abuse |
|
|