How to make an actor follow another actor within a rule?

sSHAKESssSHAKESs Member Posts: 27
edited October 2012 in Working with GS (Mac)
Hello, guys! I hope someone can help me...

I'm making a basic pong game. My swipe area to control the paddle is at the bottom of the paddle. Now, whenever I reset the ball after a goal has been made, the ball starts just above the paddle waiting to be relaunched. My problem is, I can't make the ball follow the paddle before it gets launched. I want the player to be able to move the ball with the paddle first before launching.

Any help would be appreciated. =)

Comments

  • carlblanchetcarlblanchet Member Posts: 755
    Make a real attribute called paddleX.
    In the paddle: constraint attribute paddleX to self.position.x
    In the ball: when the ball is respawned before being launched - constrain attribute self.position.x to paddleX.
  • sSHAKESssSHAKESs Member Posts: 27
    Thank you so much for the help, carlblachet.

    I've tried what you said but still no luck. When the ball resets, it resets to wherever the paddle is currently is in the x position and that is correct. But when I move the paddle, the ball doesn't go with it. And you are correct, I only want the ball to follow the paddle before it launches. Please help. =)
  • carlblanchetcarlblanchet Member Posts: 755
    Do you have a rule in there that tells the ball and paddle that the game is in standby mode (before being launched) ? If so, perhaps in not properly coded, causing it to not constraint.

    ps: Have you watched this video:

    ?

    as well as this one:

    ?
  • carlblanchetcarlblanchet Member Posts: 755
    edited October 2012
    Also make sure to add a '@' before a username so that it can be shown in the person's notifications. Like so @sSHAKESs :) (you'll even get a badge for doing so ;) )
  • sSHAKESssSHAKESs Member Posts: 27
    Yes! I think that's my problem... the being on standby mode! I'm sorry I didn't really know what was wrong but I think that's the problem.

    I have seen these videos and I have no problem on how to make the ball follow the paddle. But I'm trying to make the ball follow the paddle before it gets launched... not during the game. Any thoughts? =)

    @carlblanchet
  • carlblanchetcarlblanchet Member Posts: 755
    The option you have here, since the user is already holding the paddle before the launch, you would have to add an extra button called i.e. "Launch", "Start", or "Begin" so that the ball knows that it's being launched.

    Then you wanna have a boolean attribute, lets call it 'Playing', this attribute's default will be set to false.

    In the ball and the paddle, add the constraint rules in another rule that states if Playing is false.

    Now in the start button from the main menu, add when pressed changed attribute Playing to false, as well as in the restart button on the end screen and pause screen. Or instead of all this you could have in a timer in the scene after 0 seconds change attribute Playing to false, this way right when the scene is loaded it changes it to false.

    Add the "Launch" button on the gameplay scene and have it off screen. When Playing is false use change attribute to change its x and y position to the desired location. Also when touch is pressed change attribute Playing is true, and change attribute to change its x and y back off screen. or you could interpolate it on and off screen, its up to you.

    You will want to learn how to use multi touch in gs to be able to be touching and dragging the paddle as well as clicking the "Launch" button.

    Give this a go! :)
  • sSHAKESssSHAKESs Member Posts: 27
    @carlblanchet

    Hello, carl! Okay... please be patient with me on this one. =)

    Let's try a different approach. Right now, what I need is to make the ball visible before I press the LAUNCH button. Because right now, the ball is invisible. Everything else is fine. =)

  • sSHAKESssSHAKESs Member Posts: 27
    @carlblanchet

    Hello, Carl! You seem to be extremely helpful... I'm not sure if it's okay for me to just post my questions on other things on this thread too... but here goes...

    PROBLEMS:
    1. Make paddle stop when it hits the wall regardless of swiping extending beyond the touch area?
    2. Control the enemy's speed at following the puck? I want to make it slower.
    3. Make the ball visible in front of the actor first before launching via button?
Sign In or Register to comment.