Character Controller Cast Spell, which goes forward, until spell touch the ground, After colision in this spot with Earth, I create in Script below Wall. The problem is that The Wall is always skew.
How Can I fix it ?
public class StoneWallEffect : MonoBehaviour
{
GameObject SpellObject;
void Awake()
{
SpellObject = Resources.Load<GameObject>("Prefab/Spells/StoneWall/StoneWallEffect");
}
void OnTriggerEnter(Collider other)
{
if (other.name.Equals("Terrain"))
{
GameObject Wall = Instantiate(SpellObject, transform.position, ???????????????) as GameObject;
}
}
}
In my Prefab Wall I set Transform( Position & Rotation) to 0,
Yes I tried, It doesn’t work because, every time I createdWall, it has always the same rotation, like Prefab. Now I Try something like that:
public class StoneWallEffect : MonoBehaviour
{
GameObject SpellObject;
Vector3 PlayerPos;
void Awake()
{
SpellObject = Resources.Load<GameObject>("Prefab/Spells/StoneWall/StoneWallEffect");
PlayerPos = transform.position; // In this place I save information about Player Position, when object is born."Object" I mean magic ball which I cast
}
void OnTriggerEnter(Collider other)
{
if (other.name.Equals("Terrain"))
GameObject Wall = Instantiate(SpellObject, transform.position, Quaternion.LookRotation(PlayerPos - transform.position, Vector3.up)) as GameObject;
}
}
Created Wall looks better. But it is still problem with that, wall is not perpendicular to the Ground, I marked it on the picture.
I would start debugging this from instantiating a simple cube(with quaternion.identity)to separate whether this is a scripting issue or model issue. My guess is that it is connected to parenting/parented game objects.