How do I make a automatic linear movement?

0 favourites
  • 11 posts
From the Asset Store
Save hours of work by resizing items on your game screens.
  • Hello!

    I'm making a top down game, where cars should move automatically (without any input) from the top of the screen downwards.

    Can anybody help me with that question? Which kind of behaviour should I use?

    Thank you in advance!

  • I use the bullet behaviour.

    I put a few of the cars already on screen so there will already be traffic.

    When the cars hits a sprite at the end of the road, car is destroyed (out of the players view).

    Set that destroy sprite to invisible at On Start of Layout. So you can see it in the editor, but not ingame.

    Don't forget to set the car's Bullet Angle of Motion, when you create the cars, standard will be 90 degrees in this case.

  • Thanks, partly it works already, but how can I avoid, that the picture itself is also rotated those 90 degrees?

  • Depending on how the angle of the image was created it will be displayed that way when imported in the Sprite editor.

    You can change the angle of the image in the Sprite editor by rotating it (counter) clockwise with one of the button at the top.

    What I personally prefer is to make it so the front of the car is facing right in the Sprite editor. Then the sprite will always drive 'forward', not having to make any extra calculations when trying to make it go a certain direction in the C3 editor or when scripting.

  • thank you for your fast answers! And sorry I'm still a beginner,

    so actually the front of the car in the sprite editor is at the bottom, and the car should move to the the bottom of the screen. But till now it only works with the workaround, that the car in the sprite editor is facing to the right and then I set the angle to 90 degrees (to make it move downwards).

    This workaround works for an image, but I also would like to pin a textobject onto that car, is there a possibility to get the textobject also moving downwards without changing the angle of the text-object itself?

  • Rotate your car sprite, pin the text on your car, and then bullet (or any over behavior) the car.

  • OK, made a sample;

    Upload it to C3.

    Not sure if I can share the project 'online' I don't think so because I don't own C3.

    The Car sprite has a container which I added the Text object to. Then it will be created with the Car sprite on the same location. They will also be destroyed both, when Car hits the DestroyCar sprite.

    Find the container settings by clicking a sprite, then at the bottom left in the properties panel.

    Cars are created On Start of Layout, since they have a container.

    Note that I didn't set the Text object Pin to Car to 'Position AND Angle' but just Position.

  • It works, thank you very much! :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There is the "Car lanes" template in Construct that is pretty much the basic of what you asked, moving cars in straight lines :

    Also, in Construct, the angle 0 is facing to the right.

    So indeed, with a car "looking" to the right, to make it face to the bottom of the screen, you have to set its angle (or since you might be using the Bullet behavior, set its motion angle) to 90.

    So to pin a text object, position the text object where you want it to be (let's say car.x and car.y - 64 for example, to have it at the same X as the car but on top) and when you pin the text, use the "position only" option in the dropdown.

  • Would it also be possible to randomly spawn a text from some predefined texts?

  • Sure, use 'Choose'.

    Since you own a C3 license I'd also start using functions if you used my sample (always good anyway for recurring actions).

    I can't because I don't own a license.


    It works like:

    Text > Set Text to: choose("Text1","Text2","Text3")

    Put that action after the Car sprite is created.

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