Hi guys,
I am using Gravity Controller, which changes the player’s gravity so that they are able to walk on the side of walls, terrain, upside down, etc. I believe that is done by changing a Vector3
which I was able to track down via the Script provided in the link above.
This is the script that I am using the track the player’s gravity, and to put that Gravity Value
into a Vector3Value
object.
Summary
module = require(game:GetService("StarterPlayer").StarterCharacterScripts:WaitForChild("ModuleScript"))
local PLAYERS = module.PLAYERS
local GravityController = module.GravityController
local Controller = module.Controller
local StateTracker = module.StateTracker
local GravityState = script.Parent:WaitForChild("GravityState")
GravityState.Value = Controller.GravityUp
while 1 == 1 do
GravityState.Value = Controller.GravityUp
wait()
end
This GIF shows exactly what I mean, and that it works:
https://gyazo.com/9e4d9e2873655edadf7706f3f0579e0b
To the issue that I am experiencing
I have a script that Rotates the Player’s Character whenever the player rotates their camera. It works fine, except when I attempted to walk on a wall, the character would begin glitching out since it was locked to the camera’s rotation.
To counteract this, I made it so that the character would only be locked to the camera’s rotation whenever their Gravity
is normal. It works fine, the camera is locked on spawn, and is not locked when walking on a wall, but when returning to Normal Gravity
, the character does not lock.
This is because the Gravity's Vector3Value
does not return to a static number, and instead does this:
https://gyazo.com/42c3a6d357a956efc5b9316dcb17805b
As you can see in the GIF, is always around the Normal Gravity's Vector3
(0,1,0), but is an exponent very close to these numbers instead of being exactly.
How I believe this can be fixed
I believe that I should be able to check the Magnitude
of the Vector3
value, and see if it is within a very close range to the original. However, I am unsure of how I would do this, and this is where I need help.