Help with trajectory

m456arcusm456arcus Member Posts: 189
edited November -1 in Working with GS (Mac)
Hi,

I need some help with this one. I've seen something like what I'm going for in Mini Cannon (which is a great game btw). Anyways, what I need is an aiming system where the user touches a spot, which becomes the destination of the projectile which is thrown from a main actor. The trajectory should be a leisurely arc up then down. However, things might get complicated, because what I'm thinking is that if you touch then drag, it would be able to alter the trajectory. Just imagine drawing Bezier curves in Illustrator with the pen tool - that's what I have in mind.

Sorry if I missed this somewhere on the forums or the Wiki, but I've looked for a bit with no results other than sine and cosine, which I can't seem to modify to my liking.

Comments

  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Go to GameSalad Click New and Search for Trajectory. You'll find a good demo

    ___________________________________________________________________________________
    GS BubbleBall Template HERE!!
    Stacks Level Selection Template HERE!! Now only $20
    AppSolute Entertainment on Facebook
  • m456arcusm456arcus Member Posts: 189
    That's definitely a great demo, but not exactly what I want. Sorry to be picky. I'll see if I can modify it... In the meantime, any suggestions are really appreciated.

    The only thing different from what I'm picturing is that in the demo, you don't actually pick the spot where it'll land. Maybe I should provide the context: the game is a platformer and this is a powerup. Like a Super Mario fireball, but instead of a fixed path you tap where you want the fireball to end up.
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    m456arcus said:
    That's definitely a great demo, but not exactly what I want. Sorry to be picky. I'll see if I can modify it... In the meantime, any suggestions are really appreciated.

    The only thing different from what I'm picturing is that in the demo, you don't actually pick the spot where it'll land. Maybe I should provide the context: the game is a platformer and this is a powerup. Like a Super Mario fireball, but instead of a fixed path you tap where you want the fireball to end up.

    You will just have to play with the demo. I sure you can rework it to be where click all it pretty much takes out any challenge if it just goes where you clicked
  • m456arcusm456arcus Member Posts: 189
    tenrdrmer said:
    it pretty much takes out any challenge if it just goes where you clicked

    Yes, it takes out the challenge but that's what I want it to do. This is only going to be a small part of the game, and it shouldn't pose any sort of challenge for the user. Anyways, I'll just keep trying to modify it... Being 14, however, I don't exactly have a thorough understanding of sine and cosine... Oh well. I'll post if I find a solution. Thanks for the help tenrdrmer.
  • FangFang Member Posts: 33
    You can set up two costum attributes, "targetX" and "targetY".
    Now, take a rule, and make it so that "when mouse is down" "change attribute [targetX] to [game.Mouse.PositionX]" and "change attribute [targetY] to [game.Mouse.PositionY]"
    In your missile actor, you can have it so that for the first second, it acelerates upward with a speed of 600. Then tell it to, after the first second, accelerate towards X,Y coordinates targetX,targetY with a speed of 600.

    That's only theory. Right now, I don't have the time to test it, but I think it should work pretty well, if I understood you correctly.

    Good luck,
    ~ Fang
  • mlaftamlafta Member Posts: 147
    Fang said:
    You can set up two costum attributes, "targetX" and "targetY".
    Now, take a rule, and make it so that "when mouse is down" "change attribute [targetX] to [game.Mouse.PositionX]" and "change attribute [targetY] to [game.Mouse.PositionY]"
    In your missile actor, you can have it so that for the first second, it acelerates upward with a speed of 600. Then tell it to, after the first second, accelerate towards X,Y coordinates targetX,targetY with a speed of 600.

    Nice
    That's only theory. Right now, I don't have the time to test it, but I think it should work pretty well, if I understood you correctly.

    Good luck,
    ~ Fang

  • m456arcusm456arcus Member Posts: 189
    Ahh, good work around. That seems much simpler, although I haven't tried it just yet. And, it gives me a few more ideas along those same lines. Thanks for the help, I'll keep this thread updated.
  • m456arcusm456arcus Member Posts: 189
    Ok, so that idea didn't work quite as well as I hoped. But, with the help of a great demo, I've got a much better grasp of the move in a circle to a point thing... So the only thing I now have left to do (hopefully) is implement it into my game.
  • m456arcusm456arcus Member Posts: 189
    Anyone want to tell me why this won't work? The projectile just sits there and does nothing. Sorry to be so needy, and it's probably something so simple.

    Edit: Can't get this picture to show, but here's what I got:

    constrain pos X to: (50*cos((self.Time*-180))+100

    constrain pos Y to: (50*sin((self.Time*-180))+100
  • m456arcusm456arcus Member Posts: 189
    Nvm, got it. lol, seems like I'm talking to myself... weird.
Sign In or Register to comment.