Create moving object towards player position

0 favourites
  • 3 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hi all,

    I've been searching and fiddling but can't figure this one out.

    I have an object that has bullet behavior that moves to the right when created from a random Y position and fixed X position.

    I also have a player controlled object that can move freely with the arrow keys.

    I'd like the bullet to move towards the last position of the player when the bullet is created, however, not follow it. So basically the bullet would spawn and move in a straight line to the right and pass the player outside the window.

    Sorry if I'm overlooking something really simple. In my previous attempts the objects move towards Player.X but I'd like the bullet to pass the player by in a straight horizontal line.

    Thanks in advance for any replies.

  • I'll just give 2 examples. One with the every second condition & one using the on created condition:

    I hope this helps:

    Every Second Condition:

    *Every (3) seconds...

    ->Create Object (Bullet) at Layer ("Layer"); at X = 0 ; Y = Player.Y ;

    ->Bullet -> Set angle of motion to 0.

    ---------------------------------------------

    On created condition:

    *On (Bullet) Created...

    ->Bullet -> Set Y to (Player.Y).

    ->Bullet -> Set angle of motion to 0.

    On the every Second condition, replace the X with what you want.

    The Every Second & On created condition are both triggers. That causes each bullet to only have the player's altitude at the moment the bullets are created/

    at the moment the timer triggers

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hi chadorireborn,

    thanks so much. It's working perfectly now.

    Regards R

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)