我想射向敌人。
但我不能正确设置项目符号的方向。
我该如何设置?
这是我的代码。我该如何设定子弹朝向敌人的方向?
GameObject gm = (GameObject)Instantiate(BulletPrefab, BulletPoint.position, BulletPoint.rotation);
我想射向敌人。
但我不能正确设置项目符号的方向。
我该如何设置?
这是我的代码。我该如何设定子弹朝向敌人的方向?
GameObject gm = (GameObject)Instantiate(BulletPrefab, BulletPoint.position, BulletPoint.rotation);
i try this but still i get the wrong direction.
Vector3 dir = target.transform.position - transform.position;
Quaternion s = Quaternion.LookRotation(dir);
GameObject gm = (GameObject)Instantiate(BulletPrefab, BulletPoint.position,s);
你可以在你自己的问题下发表评论。这不是一个答案。顺便说一句,你必须在实例化对象之后使用LookRotation,而不是在它之前 – Programmer
是我的错误。 TNX虐待尝试 –
仍然无法正常工作。即时通讯看教程。在教程子弹只是一个领域,所以他没有方向问题, –
TNX,伙计们。问题解决了。
我只是创建一个空的游戏对象,并通过调整空游戏对象来修复透视。
GameObject monster = (GameObject)Instantiate(Resources.Load("Bullet"));
monster.transform.position = BulletPoint.transform.position;
monster.transform.rotation = BulletPoint.transform.rotation;
看看'Quaternion.LookRotation()' –