Arrow

quinn221quinn221 Member Posts: 280

Hi Guys,

I have a quick question. I am working on a game sort of like swamp attack. But instead of a guy shooting a shot gun, he is shooting a arrow. Along time ago I found an old posting that @Socks did on the subject of shooting an arrow. I kept this demo incase I ever needed to shoot an arrow in a game. (but now can not find the posting)

I used this demo and it works well, but the issue I am facing is the arrow stops once it gets to the mouse position. I would like the arrow to keep going until it hits the target or if he misses the target the arrow keeps going. Here is a the logic that I am using

The Spawner actor has a rule that says when mouse button is down

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. As well as two 'real' 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

Let me know if anyone has any ideas

Thanks

Comments

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

    @quinn221 said:
    the issue I am facing is the arrow stops once it gets to the mouse position. I would like the arrow to keep going until it hits the target or if he misses the target the arrow keeps going.

    If I understand the question correctly (which I probably don't), I would say you want an actor to be 'fired' towards the touch point ? And it only stops if it collides with the target actor ?

  • quinn221quinn221 Member Posts: 280

    Yes that is correct

    @Socks said:

    @quinn221 said:
    the issue I am facing is the arrow stops once it gets to the mouse position. I would like the arrow to keep going until it hits the target or if he misses the target the arrow keeps going.

    If I understand the question correctly (which I probably don't), I would say you want an actor to be 'fired' towards the touch point ? And it only stops if it collides with the target actor ?

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

    @quinn221 said:
    Yes that is correct

    Assuming the arrow starts at some arbitrary X, Y position . . .

    The Spawner:

    When mouse button is down
    --Spawn Arrow / Direction 0° / Position X, Y

    The Arrow:

    Change Self.Rotation to vectorToAngle(mouse.X-self.X,mouse.Y-self.Y)
    Change Velocity / Direction 0° [relative to actor]

  • quinn221quinn221 Member Posts: 280

    @Socks said:

    @quinn221 said:
    Yes that is correct

    Assuming the arrow starts at some arbitrary X, Y position . . .

    The Spawner:

    When mouse button is down
    --Spawn Arrow / Direction 0° / Position X, Y

    The Arrow:

    Change Self.Rotation to vectorToAngle(mouse.X-self.X,mouse.Y-self.Y)
    Change Velocity / Direction 0° [relative to actor]

    thanks!

Sign In or Register to comment.