PROBLEM WITH BOUNCING (AIR HOCKEY)

te4ote4o Member, PRO Posts: 10
edited May 2013 in Working with GS (Mac)
Hi all,
I've a problem with my first GS project and i hope that someone can help me ;)

I'm creating a simple air hockey and the bouncing of the buck it's ok.

Now, the problem is that if i move the player speedily against the puck, it doesn't work good, the puck stuck against the player and sometimes the player passes over the puck.

I'd like to have a phisical that lokes real, that when i move quickly the player against the puck, it moves in direction and speed imprinted.

(p.s. sorry if my english is not perfect)

Thanks

Comments

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    edited May 2013
    Hard to say what might be going on without seeing your rules and how the actors are set up. Have you tried adjusting the physics settings of the player and the puck? Make the players density really large, maybe like 500 and the puck much less, like 1? Just a thought...
  • te4ote4o Member, PRO Posts: 10
    edited May 2013
    First, thanks for reply Jamie.

    I try it, but it's the same. Before i had set 5000 the player and 25 the puck.

    My rules.. Uhm, just.. When the puck collide against the player i used a change attribute behavior in this way: change self.motion.linearvelocity.x to self.motion.linearvelocity.x+(self.position.x-game.Xplayer)
    and the same for y.
  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    I suggest letting the built in physics engine handle the bouncing and not coding that. I've attached a little demo that has four walls and a paddle that will shoot out balls when you press space, this is just using the GS physics engine to work. The arrow keys move the paddle up and down. Check it out...
  • themagicboxthemagicbox Member, PRO Posts: 82
    oh wow this is exactly what I posted about yesterday but no one new replied to it...

    Jamie_c...I would like to know how the the ball is able to do all the bouncing around with just the physics engine without the math I thought it would use. I use the brick breaker template and it works on there but but I tried to recreate it, it just keeps going in the same direction
  • themagicboxthemagicbox Member, PRO Posts: 82
    That's very nice that you created a zip file...I downloaded it and see that it have the collide behaviour...I think I may just build my game out of the template or the brick breaker file because that seems to be the only thing that makes sense right now...
  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    @themagicbox, feel free to use that for whatever you want. By setting up some physics in each of the actors (density, bounciness, etc) the GS physics engine does a fine job usually.
  • themagicboxthemagicbox Member, PRO Posts: 82
    Cool thanks! when you say physics what else do you mean by density and bounciness.i have played around with those..is there physics to control the direction? Because in my game I have a ball actor that moves from the bottom to the top of the screen and there is a wall it is supposed to bounce off...I put the collide behavior but it does just what I expected (it just bounces continuously into the wall) how does the collide behaviour change the direction of the ball when it collides into a wall in the template and your zip file and in my game it continues to go in the same direction, this is what is confusing me so much

    is there come kind of secret to collide or something....13 hours into this and I should have most of my levels done by now and im still dealing with this...im sorry I went to bed last night hoping to see a solution but no one replied I thought this would be a simple solution but either no one knows or no ones cares..either way it doesn't make me feel like I made a good decision buying game salad.....
  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    @themagicbox, the physics settings I'm talking about are in each actors editor under the physics tab (density, friction, bounciness, etc..). You have to set those up correctly for each actor, but it's really hard to say exactly what settings you need for your game specifically as you just have to keep playing with those values to get the right feel.

    As for how the GS physics engine actually works in creating it's angles of bounce, etc. I have no idea.

    All you should have to do is add the collide behaviors and tweek your values and usually it works pretty well. I wonder if there is something else going on/wrong with your project that is messing things up for you?

    If you're interested in sharing your project I can take a look at it and see if I see anything...
  • themagicboxthemagicbox Member, PRO Posts: 82
    edited May 2013
    Wow thank you, how do I share it, send it by email?


    okay nevermind I found your email I just sent it
  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
  • themagicboxthemagicbox Member, PRO Posts: 82
    Thankyouthankyouthankyou!!!!!!! :):):)
  • te4ote4o Member, PRO Posts: 10
    edited May 2013
    ok...
    this is a video of my problem.



    the puck bounces well against the border, the CPU player (red) and also against the green player, but if i move speedily the green player against the puck.............
    0.12s : the green player passes over the puck
    0.15s and 0.39 : the problem that i tried to explain to you
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Are you constraining that green player to the mouse? If you are constraints to the mouse override collisions.
  • te4ote4o Member, PRO Posts: 10
    The green player moves according to the touch, obviously if i try the game in gamesalad on pc the touch is simulated by the mouse. I move the player in this way: change self.position.x to game.touch1.x and change self.position.y to game.touch1.y

    How can i make it work well?
  • te4ote4o Member, PRO Posts: 10
    I fix it! Thanks for Eduard0369
Sign In or Register to comment.