Because I don't know how to use the vector.dot thing, I made a roundabout method.
There is a secondary part of an enemy that watches the player, and will change the direction of it's parent depending on where they are. the direction is based upon it's own rotation.
if(transform.rotation.y >= 0){
if(transform.rotation.y < 45){
direction = 1;
}}
else if(transform.rotation.y >= 45){
if(transform.rotation.y < 135){
direction = 2;
}}
else if(transform.rotation.y >= 135){
if(transform.rotation.y < 225){
direction = 3;
}}
else if(transform.rotation.y >= 225){
if(transform.rotation.y < 315){
direction = 4;
}}
else if(transform.rotation.y >= 315){
if(transform.rotation.y < 360){
direction = 1;
}}
if(direction == 1){
parent.renderer.material.mainTexture = tex1;
}if(direction == 2){
parent.renderer.material.mainTexture = tex2;
}if(direction == 3){
parent.renderer.material.mainTexture = tex3;
}if(direction == 4){
parent.renderer.material.mainTexture = tex4;
}
No matter where the player goes, the direction Stays at 1, despite the transform's rotation in the inspector changing depending on where the player is.
↧