So more then having a problem with a block of code I have a question regarding code structure and code layout. I see in AI scripts, co routines are the way to go. It isn’t to hard to tell why as I had my AI script to begin with THE “big ugly mess”. I had briefly read a few times about co-routines and figured the problems I would be having with my script would likely be fixed by a distinct separation. separate scripts or co routines. So now its done and its working great so I was coming to the problem of “hey that’s my enemy buddy, lets crash into him and push off course”, cause that is delightfully amusing. I tried a couple things to see if i could get relative data which a check against the enemy tag and if its index is not the index of this object then getting the other enemy data, then testing to see how close that enemy. Which this did work and I could stop my enemy, but it was very erratic. So that’s not going to be my answer. I was thinking of running a ray cast then at least if your ray casting then you know the enemy is in front of you. Upon reading about how others implemented this idea, well it looks really ugly, almost like its still not meant to be that way and your over stretching the methods purposes (with ray-casting into the angles). So now I’m wondering whats going to be good piece for this job… I know it should not only be able to test for the enemy but also the player, then it really only needs to be turned on when a condition some-wheres else it met so its not running all the time. and I thought why not use rectangles and triangles definitions in a class of “enemyF.O.V” or whatever, its on its one is specific and its easily transferable to different enemies and different styled F.O.V. make something to serve a purpose and serve it well solely.
So what I am asking is in your individual experiences and opinions what did you use and why? whats better for performance as well. Obviously nothings perfect but I’d like to see what others have to say. please I want to see the theory not to much direct code, I’ll figure something out
PS: as I wrote this i came up with a neat idea about this(sorry if this is not legible) figured id throw it in ((kinda like the class contains a list of rect transforms, accept the transforms acctualy type FOV-obj cause i’m not sure of a name so a new class inheriting from rectTrasform that contains a Type of shape)) and this^ is added into the Enemy class which would be defined in the enemy constructor because each enemy would have there individual (maybe have a few commands in case i want to modify it on the fly in game play)
but then this would then have a co-routine that when its turned on it tests all the feilds simply with a for loop that would go through the list grab the type and its coords, if triangle. im sure you get the point.
^even though i dont think i would want that to run more then once so it would be somethign better of called on the awake of this script i think.
the i would want to test for collisions with these invisableboses, so they would contain colliders? or jsut test if gameobject !=null, nope that wouldnt would cause thats this maybe the class contains a collider on it in the same shape? maybe all it needs to be is a collider oft he shape? can i use more then one type of collider on an object or in a class…