Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: mikejkelley on October 06, 2015, 09:18:07 AM
-
I have three enemies swarming the player. I want the player to be able to select the closest enemy by pressing the space bar. If he/she presses the space bar again, the second closest enemy is selected. If he/she presses the space bar a third time the third closest enemy is selected.
I have an array. All the prefabs add to the array successfully and are arranged according to their distance.
The problem is I don't see a way to continually update the list (as the distances change) since there's no Every Frame checkbox.
I'm new to ArrayMaker.
-
Is there a better way to cycle through enemies based on their proximity (other than ArrayMaker)?
-
Nobody has every needed to cycle through enemies based on proximity?
-
Hi,
Indeed many do :)
To achieve this, you can loop your state using a "next frame event" and so you achieve an everyframe system on every actions, including the one without a built in option.
Can you try this and let me know how it goes?
Bye,
Jean
-
That solves every frame. But why is that different from using a FINISHED Transition and looping back into the State?
Can you explain the Array List Sort Action? I'm attempting to sort GameObjects according to distance and Array List Sort has No Discernable Effect in my scene.
http://www.nickelcitypixels.com/cycleSelectionProximity.unitypackage (http://www.nickelcitypixels.com/cycleSelectionProximity.unitypackage)
Also while you're here, can you PM me a mailing address so that I can send you the Tobii EyeX hardware? Also also can you tell Alex that I'll be talking to the publisher this week and I'd like to give them an update? Thanks!
-
Hi,
ArrayListSort use the internal .NET sort function (https://msdn.microsoft.com/en-us/library/8k6e334t(v=vs.110).aspx), so it's no good for complex sorting, like distance.
Bye,
Jean
-
Hi Jean,
Thanks as always for your insight! Can you suggest a workaround? Thanks.
-
Hi,
yep, the workaround is to have a next frame event and loop through your list to arrange them. I have a working sample, but it's for 1.8, do you have access to the beta? else, I'll quickly refactor it for current PlayMaker version and send it over.
Bye,
Jean
-
Hi Jean,
That would be great. I've installed the beta.
-
Has anyone else tried the new Array List Sort Game Object By Distance Action? I can't get it to work.
-
Hi,
Made a quick test scene to demonstrate this action.
it's very crude, but get the job done. move the sphere and you'll see the arrayList of cubes being reordered to match by distance from the sphere.
Let me know if you still have trouble understanding its use.
Bye,
Jean
-
Hi Jean,
Thanks for the Action and example! Unfortunately what I need to do is update the array dynamically using prefabs from an object pool. This doesn't seem to do the trick:
(http://www.nickelcitypixels.com/sortDistPrefab.jpg)
http://www.nickelcitypixels.com/ArrayMakerDynamicDistanceSortingAction.unitypackage (http://www.nickelcitypixels.com/ArrayMakerDynamicDistanceSortingAction.unitypackage)
-
Hi,
this is not related and should not be a problem. you can add remove items in the ArrayList and then call this sorting actions, it will work.
Everytime you add/remove an ennemy you add it to this array, and the action will take that in consideration the next time it's processed.
Bye,
Jean
-
Hi Jean,
Thanks once again for your reply. To clarify; I understand it shouldn't be a problem, but it is a problem. If you look at the linked package, the Array List Add action isn't adding the Prefab to the ArrayList.
-
Hi,
I think you forgot to attached the package, right?
Bye,
Jean
-
Hi Jean,
It was in the previous post, I'll link again.
http://www.nickelcitypixels.com/ArrayMakerDynamicDistanceSortingAction.unitypackage (http://www.nickelcitypixels.com/ArrayMakerDynamicDistanceSortingAction.unitypackage)
Thanks as always!
-
Hi,
ok, so maybe I am not understandsing what you want.
this action assumes that you define a number of GameObjects in an arrayList so that they can be sorted by distance, but you seem to expect that it search within the hieararchy and store directly objects ? correct?
for this I would use ArrayListFindGameObjectsByTag ( and all your ennemies woudl be tagged "Ennemy"), and then you'll have your arrayList populated.
but really, since they are ennemies, you'll have do to a lot of house keeping, everytime an ennemy is created or deleted. so I would suggest that ennemies add themselves to this array AND remove themselved when killed.
Bye,
Jean
-
Hi Jean,
I need to add enemies to an array dynamically and then sort them continuously according to their distance from the player. This is needed for the purpose of cycling selection.
So far I can do anyone of these things separately but not in conjunction. For example, adding enemies dynamically by tag prohibits me from sorting them by distance (the Sort By Distance Action has no effect on the resulting array).
I can do this in code but ultimately I'd like to incld. a Playmaker tutorial on this subj. in my course. BTW, once the add and sort problems are fixed I foresee trouble w/ the cycling selection process...
-
This is the behavior I'm trying to achieve (after spawning the enemies into an array);
-
So basically cycling selection of enemies (dynamically, from a spawn pool) based on proximity.
-
Hi,
sorry, will deal with this next week, haven't had time to look at this properly yet... please keep bumping :)
Bye,
Jean
-
OK, will do, thanks!
-
Bump!
-
bump!
-
Bump! Hi Jean, you had said to msg you for a .unitypackage example, I did. Thanks! Hope to hear back soon.
-
Hi,
Did I made some progress on your case? don't hesitate to bump me, I have so many things to do, that I need reminders :)
Bye,
Jean
-
Hi Jean,
Yes, thank you it was very helpful (that doesn't mean I won't have questions later on lol). Thanks again, I understand you're super busy and I know what that's like!
-
Hi,
Good. Yes, never take it personally if I seem to have skipped something, simply bump.
I'll tag this thread solved.
Bye,
Jean