Physics - touch controls vs. keyboard - odd behavior?

ColorplayGamesColorplayGames PRO Posts: 69
edited November -1 in Working with GS (Mac)
Hi all,
I'm working on an air hockey game and I'm seeing some odd physics behavior.

When I use touch controls to move the paddle and hit the puck, the puck moves a very short distance and stops.

When (using exactly the same physics settings for the actors) I move the paddle using keyboard controls, the puck goes flying.

Is this something anyone else has run into? Any thoughts on how to get the touch controls to play nicely with the physics? I'll continue playing with the physics settings to see if I can get the touch controls to work properly but I just find it odd that the two control schemes would produce such different results.

Thanks,
Jenna

Comments

  • chosenonestudioschosenonestudios Member Posts: 1,714
    Yes, because when you move the puck via keyboard Your actually giving it a real velocity... But when you move it with your finger theres no velocity there its just the way GS reads things....

    If your applying a drag to the puck you might want to tone it down a bit :) If not You might need to give it more speed ;D
  • ColorplayGamesColorplayGames PRO Posts: 69
    Ah - thank you, that explains a lot!

    Am I correct in assuming then that I won't be able to do this with pure physics? (ie the paddle hits the puck and gives it velocity?) I guess I need to cheat and add in some velocity when there's a collision?
  • chosenonestudioschosenonestudios Member Posts: 1,714
    Hmmmm Im not sure....

    What I was going to say was: Yes you will have to add in velocity because it cant be read, but there are actually a couple of things you might be able to do...

    The idea that just came to me was... if you had an invisible object (the same size as your striker) and you constrained its position to the striker and then instead of when the striker collides with the puck, but when the invisible object collides (it would still be the same collision) since the invisible object is not being constrained by your finger, This might give it a real velocity! Not sure though, Also...

    Im also in the process of making a hockey game :D (Maybe we should start a thread for all the people making hockey games to share logic etc) But someone a month back I believe told me that you could artificially create velocity by using the x and y axis' Unfortunately I cant find the thread I started and I never got it to work even when I had it :/ Maybe If I went back now though (and found it) might be able to make it work!
  • ColorplayGamesColorplayGames PRO Posts: 69
    I suspect that velocity is just not calculated when something is moving via constraints (and possibly also via interpolation?) I've been playing around with one solution but I'm not sure how bad it will end up hogging resources:

    every .01 seconds
    Move To:
    X: game.mouse.position.x
    Y: game.mouse.position.y
    Speed = 1000

    This is the simple version (not taking into account all 5 touches, etc) but so far it's giving me the physics behavior I'm looking for with the puck!
Sign In or Register to comment.