Saturday, 28 March 2015

Unity 5: The Search for a Shield (ContactPoint)

3 Hours Research

    Shields I have learned alot about .shaders and DirectX and OpenGL. In an attempt to make a shield I have learned the basics of shaderlab and CG, as well as other shader languages. Ultimately I the only thing I have really learned is that the old shaderlab codes do not work with unity 4.6/5.

http://wiki.unity3d.com/index.php/Shield

    The goal of this was to take and modify this code. To modify you can then take Collisions, which have the method ContactPoint. This calculates the exact point of contact allowing for things to happen at the exact transform of a Collision; as well as the direction.

    Example:

foreach (ContactPoint contact in collision.contacts)
{
Object theShip = Resources.Load(EnemiesToCreate[EnemyNumber].name);
enemyShip = (GameObject)Instantiate(theShip);
enemyShip.transform.position = 
contact.transform;

}

No comments:

Post a Comment