Moving in an arc

jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
edited November -1 in Working with GS (Mac)
I'm working on an update to Z is for Zombie, and I want my player to be able to toss a pipebomb to take out a large number of zombies. I'd like it to arc up 25 pixels from it's starting position, and land at it's same Y value about 100 pixels away. anyone ever try this before?

Comments

  • HunnenkoenigHunnenkoenig Member Posts: 1,173
    There is that demo project with the cannon and the cannonball.

    Look at it. The cannonball flies an arc.
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    thanks for the tip, but I believe that flies in an arc because it's using gravity, which I don't. But I think I've figured it out, I'll post the solution I came up with if anyone is interested once I'm done.
  • HunnenkoenigHunnenkoenig Member Posts: 1,173
    Sure we are interested
  • sdparduesdpardue Member Posts: 110
    yes, please do post your solution. thanks!
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    ok, it was actually pretty easy:

    I've got an actor called pipeBomb, in it I created two custom attributes, 'arc' with a default value of 1 and 'startY'

    for rules:

    change attribute self.startY to self.positionY (this sets the pipebomb's initial start value, needed to determine when it hits ground.

    Rotate clockwise at 150 (give it a spin)

    Arc:
    while self.Arc = 1
    move up at 150
    OTHERWISE move down at 150

    ArcTimer
    after .25
    change attribute self.Arc = 0

    MoveForward
    move right at 300

    finally, the rule to cause the explosion
    if self.Position.Y is < self.startY-10 (I subtracted 10 to make it hit ground)
    spawn actor Explosion
    after .1 seconds - destroy actor

    It works pretty good, it looks like the play is lobbing the bomb, and when it hits the ground, explodes.
Sign In or Register to comment.