Help with bow and arrow

can some one help me with bow and arrow.i want my arrow to move to the place where i tap on the scree.when touch screen , arrow must indicate to that angle when released that arrow must hit that point.

Thanks in advance

Comments

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

    Two actors . . . a spawner actor and and arrow actor.

    The Spawner actor has a rule that says when mouse button is down or when touch is pressed (or whatever you want to trigger the arrow) then . . .

    Spawn Arrow

    Direction:

    vectorToAngle(Mouse.Position.X-self.Position.X, Mouse.Position.Y-self.Position.Y )

    . . . . .

    The Arrow actor has two change attribute behaviours and two interpolate behaviours . . . it also needs two 'real' attributes. Let's call the two attributes Target X and Target Y.

    Change Target X to Mouse.Position.X -half the length of your arrow* cos(vectorToAngle(Mouse.Position.X-self.Position.X ,Mouse.Position.Y-self.Position.Y ))

    Change Target Y to Mouse.Position.Y-half the length of your arrow* sin(vectorToAngle(Mouse.Position.X-self.Position.X ,Mouse.Position.Y-self.Position.Y ))

    Interpolate position X to Target X

    Interpolate position Y to Target Y

  • SocksSocks London, UK.Member Posts: 12,822
  • MalkovichMalkovich Member, PRO Posts: 116

    Thank you @Socks, i really enjoyed your demo. Good Job

  • SocksSocks London, UK.Member Posts: 12,822

    @Malkovich said:

    :smile:

  • shonasenshonasen Member Posts: 40

    Thanks @socks .I followed the steps u gave.The problem is when I start playing in my creator the bow rotates to the 270 degree and stops.I want my bow to be vertical and could move only 180 degree vertically(It is moving 360 degree now, I dont want that ).Other thing is arrow is spawn only when I released my touch on the bow (if I released the touch on the screen arrow is not spawn). I could not see your example i am using windows creator.Thanks for your help.

  • SocksSocks London, UK.Member Posts: 12,822

    @shonasen said:
    . . . when I start playing in my creator the bow rotates to the 270 degree and stops . . .

    These will very likley be caused by the rules you have used, for example do you have a rule that tells your bow actor to rotate like that ?

  • shonasenshonasen Member Posts: 40

    ya my bow has rotate to angle,as I want my bow to indicate to the target.Thanks for your help.

Sign In or Register to comment.