Player position relative to rotating platform [gif included]
So Im working with a character that can jump to a platform that rotates around itself. The problem is, when he jumps to it he's left behind by the platform and just falls down. Im trying to make it so that his position updates relative to the platforms rotation. I've tried making the platform parent of the character as soon as he jumps on it. This makes my character stand on the moving platform without getting left behind but he starts vibrating and changing his scale like this: https://imgur.com/ZfsrQHZ
Here is my code:
void FixedUpdate()
{
preserveRotation();
}
private void preserveRotation()
{
RaycastHit hit;
if (Physics.Raycast(transform.position, Vector3.down, out hit, 1.5f))
{
if (hit.transform.tag == "Rotating Platform")
{
transform.SetParent(hit.transform, true);
}
}
else
{
transform.SetParent(null,true);
}
}
anyone have any suggestions as to how to fix this? should I make an aproach other than trying to parent the character to the platform?
Your answer
Follow this Question
Related Questions
unwanted rotation in y axis 0 Answers
Rad or Deg 1 Answer
Determine object's tipping point. 0 Answers