Issue with moving center arcs (Trig Question)

LiquidGameworksLiquidGameworks Anchorage, AKMember, Sous Chef Posts: 956
edited July 2012 in Working with GS (Mac)
So, here's the issue. I need the Green Ball to go to the Black ball, but curving as to avoid the center red ball. Both the green ball and the black ball will change locations during the game(so I have the game tracking the locations). While the green ball is traveling to the black ball, the black ball is static (so it doesn't have to be a dynamic curve).

I've included a poorly drawn pic showing what I mean. Any help is appreciated! I've so far tried to utilize @P-O-M arc with marked points, and tried adapting @tshirtbooth orbits. However, trig always kicks my ass, so I've decided to come to the forums. Thanks in advance! Tagging @RThurman since he routinely has clever ideas in this field...

trig

Best Answer

  • RThurmanRThurman Posts: 2,881
    edited July 2012 Accepted Answer
    Here is a demo of the idea:
    http://www.mediafire.com/download.php?1ayen11uyshec5i

    In full disclosure, this is really Tshirtbooth's demo. I modified it to meet some of your constraints.

    (Sorry to those who are grousing about people giving away secrets/code/help. Exploring the utility of GameSalad is just too much fun to keep under wraps.)

Answers

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    edited July 2012
    @LiquidGamewords
    As a start, I'd recommend using Tshirbooth's insightful demo:
    http://gshelper.com/constrain-to-mouse-and-keep-collision-gamesalad/

    Then modify the wall actor in the demo so that it has a circle collision. See if the circle collision provides the kind of action you want.

    Edit: You might need to center a much larger invisible actor on the red dot. Then give the circle collision to the invisible actor. That might give you the larger avoidance arc you are looking for.
  • LiquidGameworksLiquidGameworks Anchorage, AKMember, Sous Chef Posts: 956
    @RThurman Thank you for taking the time to look at my question.

    I think I need to clarify a couple things. First, there is no mouse constraining, so I don't think the utilizing the velocity trick will help.

    When a particular boolean switch is true, the green and black orbs will appear in random locations. The green orb then interpolates to the black orb. We have an interpolate because we need the green orb to reach the black orb in 2 seconds, regardless of distance. If the red orb is between the two, we'd like the green orb to arc around, rather than move through the red orb. I had tried to utilize POM's demo where you defined a center point, distance, and arc height to create an arc. The game would calculate the distance and center point between the green and black orbs, and attempt to build an arc. However, it just went nuts instead.

    And now I'm going nuts :P
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    I guess I wasn't detailed enough.

    Even though the demo shows how to get an actor to chase the mouse, it does not need to be that way. You don't need to have the green orb chase the mouse. You can substitute the position of the black orb for the mouse position and it will move to the black orb.

    Tshirtbooth's demo is actually a way of doing an interpolation. It is using a form of integration to move the actor to the new location. For example, if you change the formula to only go one fourth of the way to the black orb on each iteration, you can see it move more like you are used to seeing with interpolation. The equation would be something like 5*((greenOrbX-blackOrbX)*.25)

    The time might be an issue. Does it absolutely need to be a 2 second movement each time? (If yes, you might need to think of a distance/time formula to get the correct orb speed on each iteration.)

    Is it worth pursuing this idea. Or have you rejected it already? There are other more complicated ways that involve negative-feedback control. But this is the simplest way I could quickly think of getting the effect you want. (It involves the kind of stuff that FireMapleGames did with the bouncing demo. Using Hooks law and that sort of stuff.)
  • LiquidGameworksLiquidGameworks Anchorage, AKMember, Sous Chef Posts: 956
    @RThurman I really appreciate the insight. Sometimes I just look over things, and missed how the demo could be adapted. Its late right now, but I'm going to go over this demo tomorrow and let you know how it goes. Its not so much that the timing has to be exactly 2 seconds, but it would be nice if the player had a uniform amount of time to "react" to the moving orb. I'm hoping a full night's sleep will help with the process.
Sign In or Register to comment.