Follow target behavior, I am stuck.

vaderdan

  • Posts: 117
Hi guys

I need some assistance, I have attached this behavior and it all works fine,

 but I have two questions;

1) I have four actors on the scene and when they follow my chosen target they all form as one, is there a way to separate their distance with each other?

2) Although I have to set the target within the inspector for each actor on the scene, is there a way to hard code the actor? As I require to spawn? and not place within the scene.

Thanks all,

Dan

Aim: To achieve a #1 Hit on the AppStore

polarpanda16

  • Posts: 83
1) Do they have collisions? If not you could enable collisions with each of the four actors so they can collide with each other. This can be done under Settings > Groups.

Or, you could change the walk speed of the actors that way they are never able to overlap.

You could probably make a simple behavior to detect collision with each other or location relative to each other in order to keep them separate as well.

2) I believe there is... I dont have time to explain it now but if it is unsolved when I check back later I will try to for you.

Hope this helps.
Check out my apps and other apps on the iOS App Store by searching Double Trouble Studio! Publisher of A-Mazing.

https://itunes.apple.com/us/app/a-mazing!/id542958150?

https://itunes.apple.com/us/app/drag-on/id568944870?mt=8

vaderdan

  • Posts: 117
@ polarpanda16 - I have done the collision and they separate distances, although it would be nice to set the distance apart...?

I still don't know how to hard code an actor rather than specifying it...

Thanks

Dan
Aim: To achieve a #1 Hit on the AppStore

dtrungle

  • Posts: 1938
1. You'll need to add more logic as suggested to force them not to bunch up. An easier approach is to give them varying speeds and directions along with what you have now.

2. Look in the code. The actor you set relates to an attribute (of Actor). If you can set this attribute to a specific Actor then you can change the target when you want.

vaderdan

  • Posts: 117
@dtrungle - thanks for your reply, i have been able to give varying speeds but how would you do the directions? in the code where there are the directions attribute, i removed them and put in a random number between 0 to 360 but this was very wrong.

2. In the updated event, there is target actor and when i click on it to get the list, there is no option to choose my player actor?

Dan
Aim: To achieve a #1 Hit on the AppStore

dtrungle

  • Posts: 1938
I'm not sure what the code is but I assume it's the atan one. This makes the direction equal to the target so all you need to add is a random number from (-20 to +20). This would alter the direction by a small amount, enough to be noticeable.

I believe you'll need to add in checkers for whether the attribute(actor) is alive/has value. What you need to do is pass the 'target' actor over and use it. From what I understand, you will want to create the player first, then the enemies. This way, the enemy will have a piece of code that uses 'For Each Actor of Type' block which returns the player and you can use that as the target attribute.