playMaker

Author Topic: Sophisticated move along splines  (Read 2535 times)

Bildermensch

  • Playmaker Newbie
  • *
  • Posts: 8
Sophisticated move along splines
« on: April 22, 2012, 03:30:29 PM »
Imagine you have a Network of splines. All splines start at a hub, and end at one. Every hub is start and/or end to a number of splines. Now i want a object to move along splines. On the hubs i want a random selection of the next spline, exept for the one which was used for the approach to the hub.
How would i solve this task?
Sorry if i ask a Newbieish question, may be because i am one! Thanks for Helping me with that!
Best regards
Bildermensch

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Sophisticated move along splines
« Reply #1 on: April 22, 2012, 05:21:21 PM »
Hi,

 If you need some advanced management, I suggest you look at the arrayMaker system, but if you only start with playmaker, this might be too much too soon.

https://hutonggames.fogbugz.com/default.asp?W715

 I suggest however the following approach without any thirdparty things:

Name your splines in a very clean manner ( like "spline_x" with x being the index in order of sequence without miss, 1 2 3 4, etc..), then you can generate a random int using the action "Random int", and compose a string with that int  and "spline_" as  a prefix using "build string" action. Then you find that gameObject using "findGameObject" with this string you just composed. you'll then have your random spline reference.

 Now, in order for it not to select it on its way back, it becomes trickier indeed, one dirty, very dirty solution, is to use the same routine for random int selection, but if the int is the same, then you get a new random int, until you get one different, then you compose your string, find your gameObject, etc etc.


 Does that make sense?

now, with ArrayMaker, you could maintain a list of them splines, then delete the entry of the spline you selected, and poll in that list safely because the one you picked has been removed. So all in all you would be able to achieve more complex and clener behavior by using ArrayMaker, but you'll need to get acquainted with it ( if you are coming from scripts, then it's covers the full api, so no surprised or twisted api).

 Bye,

 Jean

Bildermensch

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Sophisticated move along splines
« Reply #2 on: April 22, 2012, 11:24:37 PM »
Hello Jean,
I am with Playmaker because i failed scripting miserabling! But after all, i got some progammers genes, or else i would have failed even with PM.
Your help makes good Sense, and gives me a good idea of which Direction to go and what to explore!
Best regards,
Bildermensch