How to shoot towards a moving actor but allow the player to dodge the projectile?

FirstDanFirstDan Member Posts: 208
edited January 2012 in Working with GS (Mac)
I followed tshirtbooths video in how to recycle bullets etc. This is wired up correctly, when im shooting I am interpolating to the x and y co-ordinates of my player. When the projectiles get shot at me, it seems to always hit me, which is correct but does anybody have any idea in how i can go about allowing the player to dodge this, spent days and can't get it working.

note: I tried several ways, i interpolated
1. The projectiles self.position.x, self.position.y to players x and y
2. i also tried self.motion.linear.velocity x and y to players x and y
(Haha, when i do 2, the projectile travels in random locations.)

Happy new year

Dan

Comments

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    It might be best to add a small random element to the bullets your enemy fires than make the player dodge automatically.
  • FirstDanFirstDan Member Posts: 208
    Thanks for your advice @Bacon,

    but the problem that i seem to be having is, my shooting actor is in a non scrollable layer, when my player is within xsize 0-320 and y size 0-480, it works fine, but when my player goes greater than the y.480 my shooter actor shoots a bullet greater that where my player position is. Now if i put the shooter in a scrollable layer, this works fine but,i have to use a constrain attribute to move the shooters y position to my players y, and i do not want to do this.

    If anyone can help, awesome...
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    For firing a bullet don't use interpolate.

    Just do a change velocity. If you interpolate to the players x and y it will continually update the x and y its moving to. I personally would prob just spawn a bullet also. If the actor is small your not likely gonna notice each bullet increasing the ram or being much on the processor. For example Alpha Balls plays very well and it spawns several Thousand Bullets each round.

    Personally I think Recycling is over rated. There are definitely places it needs to be used but quite honestly on little things like bullets I don't think the benefits are worth the extra time and effort to get it working right.
  • FirstDanFirstDan Member Posts: 208
    @tenrdrmer

    Thanks for your advice, i will try that..
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    I agree tenrdrmer I spawn all kinds of stuff and with the A5 processors I think that whole debate is moot.
Sign In or Register to comment.