|
Post by wieljer on Jan 3, 2017 21:20:21 GMT
Hello!
Question for anyone that may know. FYI, don't feel like you have to write some code for me, general guidance would be fine, like what methods to use and where in v_AIController OR other class, where I can setup this behavior --
I have a building that the AI should attack. However the AI seems to want to attack the center of an objects transform, but in the case of a large square building. It can never move close enough to get to the center.
Part 1) How could I modify it so that the closest collier 'face' or 'side' could be attacked?
Part 2) And not to make it too much more complex but I'd like the AI to attack the nearest point on the facing wall of the collider regardless of how high or wide the collider is? This would prevent the AI from all smoshing up at the same location to attack the target, or running down the length of a long wall to attack it just from the center of the nearest facing collider.
|
|
|
Post by thegreatest95 on Jan 3, 2017 21:52:35 GMT
Firstly... I would simple set multiple empty GameObjects along the walls of the building. I would then raycast the enemy's position to all possible positions of say... Tag:BuildingTargets and pick the one with the shortest raycast as it's target.
Then just add that tag to the AI's targetable tags. ^_^
|
|
|
Post by wieljer on Jan 3, 2017 23:34:19 GMT
Firstly... I would simple set multiple empty GameObjects along the walls of the building. I would then raycast the enemy's position to all possible positions of say... Tag:BuildingTargets and pick the one with the shortest raycast as it's target. Then just add that tag to the AI's targetable tags. ^_^ This is good. I think if I make a building with 'hitSpots' as you've mentioned, to a local health manager, then I could have all child GameObjects along the wall reference the parent object script (lets just say) 'myHealthManager.cs' to send all updates for the damage received and when currentHealth <0 { kabloowie.Invoke(); } I think this will work pretty well. I still worry for multiple AI trying to target that point. So perhaps I can include an 'occupiedTarget' variable which the AI can read off the BuildingScript in which if already tarted by another AI that is 'melee' versus 'ranged', the melee AI won't huddle up and collide with each other constantly to hit the same point. Unless its 'occupiedTarget' = false.
|
|
|
Post by thegreatest95 on Jan 4, 2017 1:34:16 GMT
Yea an occupied bool would easily solve that issue.
Code is quick though, so if you have two AI spawn at the same time at the same spot, they would both target the same spot and both change the bool to true. So you would need to figure out a way to stop that from happening.
|
|