shoot projectile question

stse888stse888 Member Posts: 3
edited November -1 in Working with GS (Mac)
I've just started using Gamesalad and I would like to know how to fire a projectile into the distance and have the projectile arc downwards as it travels down range. I looked at the Cannon template but I don't know how to apply that example towards my situation.

Comments

  • JCFordJCFord Member Posts: 785
    Hi and welcome to game salad, I would recommend that you go through to SUPPORT at the top of this site and run through some of the basic tutorials to get an idea of how GS works first.

    Good luck
    JCFord
  • stse888stse888 Member Posts: 3
    Let me rephrase my question. I already have a projectile that is launched vertically from the bottom of the scene that's travelling towards the top of the scene. I'm looking for ideas on how to make that projectile look like it's arcing up and then dropping off into the distance. I've gone through the support section few times but it's not obvious to me right now.
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    So you mean from a top down perspective.

    I guess you would change the scale.

    So as it is fired it starts off at size 1 halfway grows to size 5 then back to size 1 where it lands/hits.

    I guess if you know how far it is going to go, you can control the scale attribute,

    or if position is less than 'A' have it increase the scale every 0.1. seconds,
    then if its is great than 'A' have it scale down every 0.1 seconds.

    And then work out what 'A' is. I guess it would vary depending how strong the power is (if that is varied?). Otherwise it would always be the same number.

    Values will no doubt be wrong but something like the following: (if this is a vertical game)

    Make a global attribute, shot_power,
    Make a global attribute, mid_shot_position

    Have a way of assigning a certain number to the shot power, be it a predefined number or one that varies on how long they hold down 'touch'.

    Then a rule on an invisible actor (purely in scene for sorting out things like this)
    mid_shot_position = shot_power x 100 (or what ever number works for you)

    then a rule on the ball,

    if position y < mid_shot_position.
    change attribute:
    (timer every 0.1 seconds)
    ball scale x to ball scale x +1
    ball scale y to ball scale y +1

    if position y > mid_shot_position.
    change attribute:
    (timer every 0.1 seconds)
    ball scale x to ball scale x -1
    ball scale y to ball scale y -1

    Then to delete ball if failed, (you may or may not want this)
    a rule like, if ball scale x = 0
    delete actor.

    hope it is of some use.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    if it is a side view just put an acceleration in the projectile with an angle of 270 (down).
  • joydeepsaha007joydeepsaha007 Member Posts: 3
    what should i have in the rules to get projectile motion??
  • StormtrixStormtrix Member Posts: 256
    might be something in ORBZ's Projectile example -
    http://gamesalad.com/game/play/80000

    not to hijack the post :) i'm also working on a missile command type game and trying to figure out
    how to keep the smoke trail (particle) on the screen till the rocket explodes at it's destination as well as
    having the rocket 'image' change it's oreintation based on the path it's traveling.
    any thoughts?
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    Add gravity
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Stormtrix said:
    might be something in ORBZ's Projectile example -
    http://gamesalad.com/game/play/80000

    not to hijack the post :) i'm also working on a missile command type game and trying to figure out
    how to keep the smoke trail (particle) on the screen till the rocket explodes at it's destination as well as
    having the rocket 'image' change it's oreintation based on the path it's traveling.
    any thoughts?

    I like to use particles for this. Just set the motion, direction, and offset to 0. then it will leave a trail behind as the projectile moves. If you want it to shoot out the back you will need to use some tricky math. I think you'll need to constrain the projectiles angle to a game attribute and then use this for the angle (+180). Not sure if that will work but setting everything to 0 and letting it trail behind works pretty well and it's easy.
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    scitunes said:
    I like to use particles for this. Just set the motion, direction, and offset to 0. then it will leave a trail behind as the projectile moves. If you want it to shoot out the back you will need to use some tricky math. I think you'll need to constrain the projectiles angle to a game attribute and then use this for the angle (+180). Not sure if that will work but setting everything to 0 and letting it trail behind works pretty well and it's easy.

    For the emitter x you would do 10*cos(self rotation), you have to choose cos from the dropdown then choose self rotation for the attribute menu. Then in y emiiter you do 10*sin(self rotation) doing the same thing for selecting sin and self rotation. Then if you want to play around with there position just change the 10 in the expressions to whatever. Just make sure that number stays the same for both x and y.
  • crapscraps Member Posts: 353
    "ball scale x to ball scale x -1"

    Is there really a scale function? I cant seem to find it.
Sign In or Register to comment.