Toss a ball in an arc?

fogartyfogarty Member, PRO Posts: 181
edited May 2012 in Working with GS (Mac)
I'm sure this is easy, but I can't think of a way to do it!

How do I make an actor toss a ball and have the ball go in an arc until it reaches a certain point on the screen (not the bottom)?

Best Answers

  • tatiangtatiang Posts: 11,949
    Accepted Answer
    If you search for "arrow" in GameSalad under New, you can find a good demo called "Beyond the basics." I used this for a golf ball in flight and it worked well.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • JohnPapiomitisJohnPapiomitis Posts: 6,256
    Accepted Answer
    Im running out the door to eat right now, and can provide more help later. But off the top of my head sin and cos for an arc would be something like this.

    Constrain self position x to -130*cos(self.Time*100%180)+offset
    Constrain self position y to 130*sin(self.Time*100%180)+offset

    The 130 represents the radius of the arc. The minus in front of the 130 in the x constrain is to make it to left to right instead of right to left. The 100 is the speed. The 180 represents the arc as a half circle(half of 360), and the offset is its starting position in the scene. The self.Time just represents a value that keeps changing to keep it in movement. It can be any changing value, doesnt have to be time. As soon as that value stops changing the actor will stop moving.

    When i get back home ill help you more.

Answers

  • fogartyfogarty Member, PRO Posts: 181
    Thank you!
  • fogartyfogarty Member, PRO Posts: 181
    Oh, cool. Thanks, @tshirbooth!

    That is what I mean...like a monkey tossing letters into a basket.
  • fogartyfogarty Member, PRO Posts: 181
    Did I mess it up by clicking "Accept Answer"? Will @JohnPapiomitis not see it now?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    i suck at sin cos
    So do I.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • fogartyfogarty Member, PRO Posts: 181
    Wow. Thanks a bunch to both of you!
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    You two with your joint Gamesalad maths wisdom. You just need 3 more experts and then you can start the Gamesalad fantastic 5. Imagine the power you could use it for good or evil.

    (bit random I know, but it's late and I've got square eyes from too much audio editing for my game).

    Nice to see the forum being its good old helpful self.
  • fogartyfogarty Member, PRO Posts: 181
    @tshirtbooth I figured it out when I looked at the code. "When touch is pressed..." :-)
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    @thirtbooth

    Teamwork makes the dream work :)
Sign In or Register to comment.