Make ball go in direction of arrow?

ZombiebrainsZombiebrains www.zombiebrains.co.ukMember, PRO Posts: 296

Hi Folks

I'm working on my next app and I need some help on getting a golf ball to move in the direction that an arrow is facing.

I have a golf ball actor and a long arrow actor.

Now, the arrow actor rotates sit in the middle of an iPad landscape scene (1024 x 768) and spins at 100 on the speed and this obviously points towards the edge of the screen.

Now, I want a golf ball actor that sits in the middle (On top of the actor) of the screen to fire towards the direction the arrow was facing.

How can I make it so that Gamesalad sort of can tell what direction the arrow is facing so it shoots in that direction...been bugging me all day!

Any clues would be great!

Thanks folks.

It takes a Zombie to know a Zombie!!!

Comments

  • TosanuTosanu Member, PRO Posts: 388

    Make Game Attribute: Arrow Direction. Make it an angle type.

    On the arrow, set this. Constrain Attribute: Arrow direction to Self.Rotation.

  • ZombiebrainsZombiebrains www.zombiebrains.co.ukMember, PRO Posts: 296

    @Tosanu said:
    Make Game Attribute: Arrow Direction. Make it an angle type.

    On the arrow, set this. Constrain Attribute: Arrow direction to Self.Rotation.

    Wow, that's great! Thank you so much...was making my head hurt! :)

    It takes a Zombie to know a Zombie!!!

  • TosanuTosanu Member, PRO Posts: 388

    Just make sure the arrow is pointing right at 0 rotation or it wont line up.

  • ZombiebrainsZombiebrains www.zombiebrains.co.ukMember, PRO Posts: 296

    @Tosanu said:
    Just make sure the arrow is pointing right at 0 rotation or it wont line up.

    Hi Tosanu

    Thanks so much for that update...I would have probably had it pointing up :)

    Another question?

    How do I get the ball to go in the direction the arrow is facing if it's spawned in the centre of the screen at the same location the arrow is?

    Thanks in advance

    It takes a Zombie to know a Zombie!!!

  • TosanuTosanu Member, PRO Posts: 388

    You have the ball spawned in direction SavedAngle(or whatever you called the angle you grab from the arrow) and then set it with a change Velocity behavior at the start of its backstage with a direction 0 relative to actor. That way it willl shoot forward in whatever direction it is initially facing.

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2014

    As the ball will automatically inherit the spawner's rotation you don't really need the constrain behaviour in the arrow, nor do you really need the attribute that passes the arrow's angle to the ball . . . . . simply use the ball's own rotation at birth to define which direction it goes in (using move or accelerate or change velocity . . . etc)

    Example: https://www.mediafire.com/?uxgfsjrea20qsrx

    Click on the arrow to generate a ball.

  • ZombiebrainsZombiebrains www.zombiebrains.co.ukMember, PRO Posts: 296

    @Socks said:
    As the ball will automatically inherit the spawner's rotation you don't really need the constrain behaviour in the arrow, nor do you really need the attribute that passes the arrow's angle to the ball . . . . . simply use the ball's own rotation at birth to define which direction it goes in (using move or accelerate or change velocity . . . etc)

    Example: https://www.mediafire.com/?uxgfsjrea20qsrx

    Click on the arrow to generate a ball.

    Thanks guys that makes sense now.

    Socks! Great demo and it explains the logic great... :)

    It takes a Zombie to know a Zombie!!!

Sign In or Register to comment.