I was wondering what the best way to tell when a player or part has completed a in air rotation.
Such as a 360 spin or other orientation related movement.
I already created a script that fires a function when a player spins their character around 360 degrees while mid air using some basic math. However, it is not very consistent.
I would modify the core scripts which the cameras use, find where they apply the delta changes to the camera pan for any mouse movement, add that up and calculate based off those numbers.
The reason I have not tries this already, is because my games core scripts are completely modified, and I don’t even use half of them. I custom made most of the camera movement and character movement scripts, therefore I can’t use roblox’s stuff to my advantage. I should have mentioned this in the post, but I need to somehow make the calculations based off of HumanoidRootPart orientation or CFrame data. Unless someone else can find another way to do it, of course.
I would probably get the angle of the look vector when the user initially jumps, then on each frame get the delta angle of their lookVector and at it to a revolution counter variable, if it turns 360 degrees relative to its initial start angle you can say it’s done x revolutions. e.g. track this:
local d = math.atan2(-part.CFrame.lookVector.x, -part.CFrame.lookVector.z)
current_ang = current_ang + d
if math.deg(current_ang) % 360 == 0 then
-- stuff
end
Obviously needs to be more developed than that, you need to track the intial angle as I said, and then figure out whether it’s a full revolution relative to that
So this is why I had a variable referenced as ‘current_ang’, if you measure the delta angle at each frame, you can continuously add this to the ‘current_ang’ variable, so you end up with a variable defining the total rotational movement of the object. You can then determine if it’s rotated 360 or more
Thank you so much. I will create something that works like this. I was trying to do the calculations based off of the final difference between the orientations, but I will need to be tracking it all throughout the jump.