Hello
Is there a easy way to flip/scale sprite in dialogue so it looks like character is turning to speaker?
Flip Sprite
Re: Flip Sprite
Hi,
You can add a script with an OnConversationStart method to the character.
The implementation may depend on the specifics of your game. For example, say that your characters use a SpriteRenderer with a sprite that by default faces right. To face left, you set the SpriteRenderer's Flip X bool to true. Then your script's OnConversationStart method could look like:
You could do something similar if you make characters change direction by setting transform.localScale.x, or by setting the transform's Y rotation to 0 for right or 180 for left, etc.
If your characters have turn animations, you might want to get fancier and make the character play a turn animation. It's up to you.
You can add a script with an OnConversationStart method to the character.
The implementation may depend on the specifics of your game. For example, say that your characters use a SpriteRenderer with a sprite that by default faces right. To face left, you set the SpriteRenderer's Flip X bool to true. Then your script's OnConversationStart method could look like:
Code: Select all
void OnConversationStart(Transform other)
{
if (other != null && other != this.transform)
{
GetComponent<SpriteRenderer>().flipX = other.transform.position.x < this.transform.position.x;
}
}
If your characters have turn animations, you might want to get fancier and make the character play a turn animation. It's up to you.