Help with bow and arrow
shonasen
Member Posts: 40
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
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
Example:
https://www.mediafire.com/?ic0mjg5ampg4vwl
. . .
Thank you @Socks, i really enjoyed your demo. Good Job
Nix the Cat: Jump Adventure * Twitter * Facebook
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.
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 ?
ya my bow has rotate to angle,as I want my bow to indicate to the target.Thanks for your help.