c# - Unity2D局部比例问题
问题描述
我有一个 2d 平台游戏,并且有这些带有巡逻系统的敌人:
public TextMeshProUGUI m_Object;
public SpriteRenderer sp;
public Transform groundCheck;
bool isFacingRight = true;
RaycastHit2D hit;
private void Update()
{
hit = Physics2D.Raycast(groundCheck.position, -transform.up, 1f, groundLayers);
}
private void FixedUpdate()
{
if(hit.collider != false)
{
if (isFacingRight)
{
rb.velocity = new Vector2(speed, rb.velocity.y);
}
else
{
rb.velocity = new Vector2(-speed, rb.velocity.y);
}
}
else
{
isFacingRight = !isFacingRight;
sp.transform.localScale = new Vector3(-transform.localScale.x, 1f, 1f);
Debug.Log(transform.localScale.x);
float placeholder = sp.transform.localScale.x;
m_Object.transform.localScale = new Vector3(placeholder, 1f, 1f);
Debug.Log(m_Object.transform.localScale.x);
}
}
在最后部分,我试图翻转文本,使其保持面向逻辑的方式,但是它不起作用,因为当它碰到边缘时,文本消失了,当它到达另一个边缘时,文本又回来了。
任何想法,将不胜感激。
解决方案
推荐阅读
- python - 如何在 9.414 版本中使用 executemany 忽略 postgres 中的重复项?
- javascript - $ character in ReactJs
- redundancy - 在链接失败的情况下将请求重定向到其他 IP 地址
- python - TensorFlow 在集群上运行(40k 核心,500TFLOP/s 和 40k RAM)与 NVIDIA GTX 1080
- swift - 如何动态更改 PageViewController 中的背景?
- reactjs - 会话存储无法保存在 reactjs 应用程序中
- jquery - HTML5 日期时间-本地。如何只接受 Ymd
- java - 有人可以解释这些通用语法吗?
- android - Crashlytics 报告错误的行号
- r - Shiny Server - 托管其他应用程序的问题