我正在施放一些咒語,並將其設置爲LookAt
。問題是LookAt
正在將我的法術動畫設置爲不在遊戲對象中。我從中獲得的位置的對象具有比例(3,3,3),網格渲染器,球面碰撞器和剛體。 (其他碰撞體在子對象上)。下面是我使用的鑄造法術代碼:transform.LookAt正在關閉遊戲對象
public void castSpell(GameObject caster, Transform otherTransform, float duration)
{
if(animationEnabled)
{
foreach(var a in animator)
{
foreach(var b in a.bools)
{
a.animator.SetBool(b.parameterName, b.parameterValue);
}
foreach(var i in a.ints)
{
a.animator.SetInteger(i.parameterName, i.parameterValue);
}
foreach(var f in a.floats)
{
a.animator.SetFloat(f.parameterName, f.parameterValue);
}
}
}
GameObject Temporary_Spell_Handler;
Temporary_Spell_Handler = Instantiate(_Spell, Spell_Emitter.transform.position, Spell_Emitter.transform.rotation) as GameObject;
ParticleSystemRenderer pr = Temporary_Spell_Handler.GetComponent<ParticleSystemRenderer>();
float dist = Vector3.Distance(caster.transform.position, otherTransform.position);
//Add Spell Script to the casted spell so it handes damage and everything about spells.
Spell tempSpell = Temporary_Spell_Handler.GetComponent<Spell>();
tempSpell.caster = caster;
if(b_lenghtScale)
{
pr.lengthScale = -lenghtScale;
}
if(lookAtEnemy)
{
Temporary_Spell_Handler.transform.LookAt(otherTransform);
}
Destroy(Temporary_Spell_Handler, duration);
}
,這裏是像它看起來的樣子:
我發現這個問題。我的ball
被縮放到(3,3,3),所以它上升並且對象的支點停留下來。那我該如何克服這個問題呢?
我不確定是什麼問題。你能添加一個你期望*發生的截圖嗎? – Draco18s
你看到閃電正在地面,而不是球(談到雷電中心)。所以我想以某種方式改變角度。 –
這將完全取決於你的對象的設置和性質。如果閃電的圖形與遊戲對象的軸線不對齊,則圖形需要修復。如果預製平面與軸不對齊,那麼需要固定。如果預製軸沒有指向你希望它指向的位置,那麼這就是完全不同的問題。*我無法從你發佈的圖片中知道它是哪一個。 – Draco18s