playMaker

Author Topic: Array Filter  (Read 1480 times)

Goldo_one

  • Playmaker Newbie
  • *
  • Posts: 2
    • View Profile
Array Filter
« on: November 29, 2016, 01:35:29 PM »
Hello,

This is my first post and request. Firstly, thank you all for your works on playmaker stuff^^

My situation :

1. I have my character(A) jumping on a movable placeholder object(B).

(B) contains some children objects: visual, snapPoints, etc.

2. But i want (A) snap on specific locations of (B). So i created some SnapPoints(children with specificTag).

(A)-->raycast player front -->get(B)-->arrayListGetAllChildOf(B) with "ONLY" snapPoint(tag)

It miss the possibility to "Filter" the arrayListGetAllChildOf. Create a list from a parent, to get all the children with a specific Tag.
   -Or other action to remove from the list all object without specifictag.
   -Or get a filtered Array from an existing list.
             ex:  input : existing array list
                   tag = ""
                   ouput : new list (with only tag object)

3.then i use ArrayListGetClosestGameObject(of my snapPointList).
4.then MoveToward my player TO the snapPoint.

For now i use fromRaycastedObject(B)  =  GetNextChild-->GameObjCompareTag-->ArrayListAdd-->loop, but it's not elegant.

That's it. And if you have a better method about my gameplay situation, don't hesitate.


Thank you.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15426
  • Official Playmaker Support
    • View Profile
Re: Array Filter
« Reply #1 on: December 01, 2016, 02:19:39 AM »
Hi,

 Hello and welcome :)

You can iterate the array and save what's of interest to you in a second array, so your list of child is a raw list, and theny ouy have your final list with only the child of interests.

- why not using triggers? you could avoid having to manually do a similar system of proximity detection, triggers are perfect for this. than you maintain a list of what's currently triggered on your player and you can then find out the closest.
 
 Bye,

 Jean
« Last Edit: December 13, 2016, 04:02:25 AM by jeanfabre »

Goldo_one

  • Playmaker Newbie
  • *
  • Posts: 2
    • View Profile
Re: Array Filter
« Reply #2 on: December 06, 2016, 02:24:05 PM »
Thanks jean, thanks for the method.


Why the raycast rather than proximityTrigger, i don't know. It s for a mobile game. So i ask for 1 frame, for a specific location (crossy road like) ! it looks likes less  expansive ..but i never verify.

In other case, when my player hold touch, the character pre-Anim. When player release , the character jump forward. But if there is an obstacle, the pre-anim roll back, and you stay at the same position.
So my need was to check in front of him (or side depending the requested direction) before jumping.
Raycast is usefull for that.

It's possible to offset a trigger to check that.. but... that's seems not elegant solution.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15426
  • Official Playmaker Support
    • View Profile
Re: Array Filter
« Reply #3 on: December 14, 2016, 02:46:57 AM »
Hi,

 Triggers are very performant, don't underestimate them :)

 Bye,

 Jean