0
Answered

Character flying away when teleport and rotate

Erica 5 months ago in Game Creator updated by Marti (Lead Developer) 5 months ago 3

Hi.

I'm creating a bed which the player can sleep on. It is set up with two markers (one beside the bed and one on top), and a mouse click trigger to run an Action that looks like this:


(The "Change Player IsControllable" just sets it to false, but the behavior is the same regardless of whether it is present or not).

I also have a custom character state called "Sleeping", which is just a Simple CharacterState with an entry, an idle and an exit animation.

Now this code... Works. Mostly. Except that the animation results in the player lying sideways across the bed in a very impractical manner. ;)

My thought here was simply to check "Rotate" on in the "Teleport Player to M - On Bed" line item, which would make the player align correctly. However, whenever I turn this on, regardless of the actual rotation of the Marker, the character immediately and rapidly slides off the bed, along the ground, and right off the edge of the map.

I've tried turning off IK flags. I've tried changing the rotation of the bed and both markers. I've tried raising the marker, in case it was something to do with collisions. I've tried moving the teleport step before the change state, and after it. The behaviour remains the same in all cases. The character lies down sideways if I don't rotate, and slides off into the ether if I do rotate.

I have no idea what's going wrong here, or how to fix it.

Help?

Unity version:
2019.3.11f1 Personal
Game Creator version:
1.1.6 - PATCH

Answer

Answer
Under review

If I'm not mistaken, the problem could be that the bed has a collider and the player has another one. That's why both can't coexist on the same place. If that's the problem, the solution then is simple. Right before the last Teleport action, add another action called "Mount Character". This is meant to be used to make a character enter a vehicle. However, in this case should work just fine.

Another thing, but this is just a recommendation. Instead of using the Teleport, which will make the character instantly snap onto the bed, try using the "Move Transform" action. Might look better, as you can gracefully move the character to the bedside.

But let's not get ahead. Hope this helps! I'm leaving this thread as Under Review until we can confirm this solves the problem. Cheers!

Answer
Under review

If I'm not mistaken, the problem could be that the bed has a collider and the player has another one. That's why both can't coexist on the same place. If that's the problem, the solution then is simple. Right before the last Teleport action, add another action called "Mount Character". This is meant to be used to make a character enter a vehicle. However, in this case should work just fine.

Another thing, but this is just a recommendation. Instead of using the Teleport, which will make the character instantly snap onto the bed, try using the "Move Transform" action. Might look better, as you can gracefully move the character to the bedside.

But let's not get ahead. Hope this helps! I'm leaving this thread as Under Review until we can confirm this solves the problem. Cheers!

+1

Mount seems to be exactly what I was looking for - even covers the need to toggle isControllable. Thank you! :)

Answered

Awesome! Happy to help :-)