Search Unity

Design Ping Ping 3D game

Discussion in 'Scripting' started by gbk123, Sep 27, 2011.

  1. gbk123

    gbk123

    Joined:
    Sep 22, 2011
    Posts:
    3
    hi
    i am beginner with using 3D unity , i have only 3 days to learn it and now only one day left , i have read the basic tutorials and some examples to start designing the game .

    so far i managed to design the basic things but i just can't figure out , what is the script to make the players interact with each other !! i mean when player 1 hit the ball , player 2 should hit back ...... still have no clue how to do it .

    the only way that i think about that to set the ball as a target then make player 2 moves to that target , but i don't know how to make the player move toward the target .

    one more thing PLEASE , i have edit the animation curve for the ball but when player 1 hit it , it act like a football , so basically i have designed a football game with only one player !!!!

    ?? any idea please ?? i appreciate any help

    THANK YOU
     
  2. cat_ninja

    cat_ninja

    Joined:
    Jul 14, 2010
    Posts:
    197
    Well actually use the physics engine, have the ball move normally without friction, some physics materials should help. If that's not what you're going for make a script that changes the direction of the velocity of the ball when it hits the player. But try the first one it'll work better
     
  3. Biggz

    Biggz

    Joined:
    Aug 29, 2011
    Posts:
    23
    Personally I wouldn't use the physics system... but that's just my preference, I really don't know which way is "better".

    Every Update() I would transform.translate the ball along one axis. Then, whenever the ball collides with a paddle, inverse that axis so it goes back in the other direction.
     
  4. gbk123

    gbk123

    Joined:
    Sep 22, 2011
    Posts:
    3
    thank you both for your help !

    ( cat_Ninja)
    i am not sure how to use the physics to add curve to my ball to make it behavior like a ping pong game, any help is there any tutorial ! and any advice how to make the second player automatically toward the ball when the player 1 hit it !

    ( biggz)
    transform.translate so if i use this function into one axis right ?? will that make the ball curve like ping pong ??? and i appreciate any advice how to make the second player automatically toward the ball when the player 1 hit it !
     
  5. cat_ninja

    cat_ninja

    Joined:
    Jul 14, 2010
    Posts:
    197
    Uhh I'm not sure what you mean to add a curve to the ball? Pong usually has the ball moving straight. Also I realized maybe using the physics engine raw isn't a great idea, I noticed in pong the ball hits at different angles depending on how far away from the center of the paddle. So try something like that.