Michael Jackson characters

OK I couldn’t find a better title for this problem, but… my player and enemy, which are both at war, look like Michael Jackson here (i.e: they’re rotated, not straight), as you can see below. Why is this happening?

Try going into your Capsule Collider and checking the box Freeze Rotation on the X and Z.

I went into the prefabs of the character, didn’t find a ‘Freeze Rotation’ for any axis in my Capsule collider (where is it hidden, or can we code it instead…?). If it helps in anyway, I’m using Unity 2021 LTS

(Edit: Found one under the Rigidbody → “Constraints”, and it still didn’t fix it…)

You have a knack for encountering problems that make no real sense…

It’s possible this is a result of transform.LookAt, although the characters look like they are the same height, so I completely discounted it.

Where you are using transform.LookAt(), you might try making a modification that adjusts for the y component…

void LookAt(Vector3 position)
{
    position.y = transform.position.y; //equalizes height 
    transform.LookAt(position);
}

Well, we are exploring and learning… :stuck_out_tongue_winking_eye:

On a serious note though, placing this code in ‘Fighter.cs’ as a ‘LookAt()’ function, and then replacing ‘transform.LookAt()’ with this block of code in ‘Fighter.AttackBehaviour()’, after checking for my lineOfSight, which ensures we don’t fire ranged weapons through static objects, solved the problem. Thanks again Brian

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.