About shooting.

I know how to make an actor shoot an other one, but here is my problem. Both the bullet and the main actor are accelerating. which means if i shoot a bullet the bullet lags behind. if i change the bullet from accelerating to moving, then the main actor will accelerate past the bullet even faster, which makes it even worse. How do i make the bullet constantly moving faster than the main actor even from the start?

Comments

  • dr2391dr2391 PRO Posts: 78
    I'm not sure if by "changing the bullet from accelerating to moving" you mean that you used change velocity instead of accelerate, but try this in the bullet...

    change attribue
    self.motion.linearvelocity.x to 500(or whatever speed you want)

    if that doesn't work, you could also try...

    Make a real attribute called PlayerSpeed

    In the player...
    constrain attribute
    self.motion.linearvelocity.x to game.PlayerSpeed

    in the bullet
    constrain attribute
    self.motion.linearvelocity.x to game.PlayerSpeed+300(or whatever speed you want)
  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2013
    @dr2391

    Agreed, I was about to post the same basic idea, simply add the player's speed to the bullet's speed - so that the bullet moves at a constant speed in relation to the player.

    One small point, you have this rule back to front:

    constrain attribute
    self.motion.linearvelocity.x to game.PlayerSpeed


    It should read:

    constrain attribute
    game.PlayerSpeed to self.motion.linearvelocity.x
  • dr2391dr2391 PRO Posts: 78
    Good catch @Socks

    Thanks!
  • AleksandrGamesAleksandrGames Member Posts: 54
    Thank you both! it worked perfectly!
Sign In or Register to comment.