Hiya again!
Sorry for the bother but I'm running into a weird issue with GetNextSegment and GetPreviousSegment I'm at the point where I'm trying to get the player attached to the box and I want to rotate them around the ledge by being attached to the box.
Currently if I use GetPreviousSegment it works fine and my character spins around the box at light speed in the reverse direction, skipping CP0
If I do GetNextSegment however, they make it to CP0 and then it just stalls and the character won't move around anymore.
I tried using GetNextControlPointUsingFollowUp as well but it still got hung up on the same spot
Apologies for the spaghetti code I was planning on cleaning it up much more once I got it actually working haha
--Edit-- nevermind sorry for the bother but I managed to get it working in a very silly way by taking use of the built in spline controller to handle smoothly moving it works now! if you have a better way that i should have done it i still would like to hear tho
Sorry for the bother but I'm running into a weird issue with GetNextSegment and GetPreviousSegment I'm at the point where I'm trying to get the player attached to the box and I want to rotate them around the ledge by being attached to the box.
Currently if I use GetPreviousSegment it works fine and my character spins around the box at light speed in the reverse direction, skipping CP0
If I do GetNextSegment however, they make it to CP0 and then it just stalls and the character won't move around anymore.
I tried using GetNextControlPointUsingFollowUp as well but it still got hung up on the same spot
Apologies for the spaghetti code I was planning on cleaning it up much more once I got it actually working haha
Code:
IEnumerator ShuffleLeft(float waitTime){
var lookPos = transform.position - player.transform.position;
lookPos.y = 0; //lock
if (lookPos != Vector3.zero){ //need this to fix an error being spammed
var rotation = Quaternion.LookRotation(lookPos);
}
nearestTF = Spline.GetNearestPointTF(transform.position, Space.World);
nearestTFSegment = Spline.TFToSegment(nearestTF);
CurvySplineSegment nextSegment = Spline.GetPreviousSegment(nearestTFSegment);
float nextTF = Spline.SegmentToTF(nextSegment);
Debug.Log(Spline.GetNextControlPoint(nextSegment));
Quaternion nearestOrientation = Spline.GetOrientationFast(nextTF, false,Space.World);
transform.rotation = nearestOrientation;
ledgeHitBoxPosition = Spline.Interpolate(nextTF, Space.World);
transform.position = ledgeHitBoxPosition;
player.transform.position = new Vector3(ledgeHitBoxPosition.x,ledgeHitBoxPosition.y-1.185749f,ledgeHitBoxPosition.z);// moves the player vertically into place
playerNearestOrientation.Set(player.transform.rotation.x,nearestOrientation.y,player.transform.rotation.z,1);
lookPos = transform.position - player.transform.position;
rotation = Quaternion.LookRotation(lookPos);
player.transform.rotation = Quaternion.Slerp(transform.rotation,rotation,0f);
player.transform.Rotate(11,-90,-180); //rotation offset
yield return new WaitForSecondsRealtime(waitTime);
shuffling = false;
}
--Edit-- nevermind sorry for the bother but I managed to get it working in a very silly way by taking use of the built in spline controller to handle smoothly moving it works now! if you have a better way that i should have done it i still would like to hear tho