Making multiple "Cars"?

0 favourites
  • 11 posts
From the Asset Store
Make your own platformer for both the web and mobile easy with this Santas Platformer Template, FULLY DOCUMENTED
  • The way I have it set up is that I enter the car, and it destroys the player and pins the camera to the car. When I leave, it spawns the player nearby the car and pins the camera back to the player. If I have multiple cars, it will pin the camera between the two cars, and then control both cars. and when i leave that car, it spawns multiple player objects. How do i prevent this?

  • You have to pick the right car with condition beforehand. Can you post capx or picture with code where car entering is managed?

  • Car.Pick Nearest (Player.X, Player.Y)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You have to pick the right car with condition beforehand. Can you post capx or picture with code where car entering is managed?

    Here is the .capx.

    EDIT: Cant post links, i also can't private message. How shall i do this?

    EDIT 2: Now i can actually post links, here's the CAPXhttps://docs.google.com/uc?id=0Bx4FI3LqqX93WV9mY0J5T1d0dm8&export=download

  • For some reason your game does not work on my crappy PC I have here, so I cannot test it but hope this will work. Also your game is HUGE, 22mb, I would recommend compressing some of the music.

    Problem is that you have not designated your car so game is using all cars available.

    One solution would be to create global variable which will store "license plate" or "UID" of a driven car. (as I did between line 43 and 44 on this picture and called it carUID)

    Then when you enter the car you will have to put its UID into that variable (last action on line 44)

    Then you will have to pick said car by that variable before you do anything with it. (line 38 and line 46).

    Also in every other action where your driven car is doing anything, it will have to be picked same way.

    Hope it works now.

  • The way I have it set up is that I enter the car, and it destroys the player and pins the camera to the car. When I leave, it spawns the player nearby the car and pins the camera back to the player. If I have multiple cars, it will pin the camera between the two cars, and then control both cars. and when i leave that car, it spawns multiple player objects. How do i prevent this?

    not sure if u fixed it but im guessing when u are between 2 cars, the player is spawned on exit and overlaps both of them thats why is ur code creating to many players on exit, as you code is sayng > when player ovelaps car disable driving spawn player .... that means when ever u have 2 cars and the cars are overlaping him each of the car will spawn a new carachter at their own origin point 1 on layer 0 so make sure both of the cars dont overlap the carachter or try using variables instead or boleans will be much simple and will avoid the confusion of graphics overlaping , thats for platformers then what u have here (old gta format i guess) , so try do a bolean called driving on character and say when E is pressed and Bolean is not active set bolean to true and do the rest for driving the car if bolean is active when E is pressed then set bolean to false and spawn 1 carachter and try using a sub event on spawn that says trigger event once (cause if u dont use the trigger event , then the engine will try spawn as many possible characters in the time frame, that takes to spawn a character for the engine). hope it makes sense and helps u

  • For some reason your game does not work on my crappy PC I have here, so I cannot test it but hope this will work. Also your game is HUGE, 22mb, I would recommend compressing some of the music.

    Problem is that you have not designated your car so game is using all cars available.

    One solution would be to create global variable which will store "license plate" or "UID" of a driven car. (as I did between line 43 and 44 on this picture and called it carUID)

    Then when you enter the car you will have to put its UID into that variable (last action on line 44)

    Then you will have to pick said car by that variable before you do anything with it. (line 38 and line 46).

    Also in every other action where your driven car is doing anything, it will have to be picked same way.

    Hope it works now.

    How exactly do I do the pick car with UID thing, it doesn't show up at all in my list.

  • > For some reason your game does not work on my crappy PC I have here, so I cannot test it but hope this will work. Also your game is HUGE, 22mb, I would recommend compressing some of the music.

    >

    > Problem is that you have not designated your car so game is using all cars available.

    > One solution would be to create global variable which will store "license plate" or "UID" of a driven car. (as I did between line 43 and 44 on this picture and called it carUID)

    >

    > Then when you enter the car you will have to put its UID into that variable (last action on line 44)

    >

    > Then you will have to pick said car by that variable before you do anything with it. (line 38 and line 46).

    > Also in every other action where your driven car is doing anything, it will have to be picked same way.

    >

    > Hope it works now.

    >

    How exactly do I do the pick car with UID thing, it doesn't show up at all in my list.

    EDIT: I've figured it out! Instead of doing the pick instance with uid thing, i used "pick car where car.uid = carUID" as a substitute.

  • Hm, is it possible that DEMO construct prevents this? You should select car and then "Pick by unique ID"

    Maybe you searched UID?

    BTW does it work now?

  • I just now found it, but using the way I showed in the above post does work. Do you know why I can't set the car to be only entered on touch, not overlapping? I'd like to have my cars not go through eachother but I'm not sure how to fix it. And I'd rather not start a whole new discussion if possible.

  • I just now found it, but using the way I showed in the above post does work. Do you know why I can't set the car to be only entered on touch, not overlapping? I'd like to have my cars not go through eachother but I'm not sure how to fix it. And I'd rather not start a whole new discussion if possible.

    This is what would I do :

    1. your cars need solid behavior

    2. since you cannot overlap them with player any more (because of solid behav), I would turn 43 into that on picture

    (I set minimum distance as Car.Height, you can sat anything else you want, it must be bigger than sides of car)

    Also other suggestions:

    3. your hit box on Car, Player and some other objects is too complicated, you have more than 10 collision points on them. That will eat resources of any computer that tries to run it. You can put it in 4 points, nobody till complain if small part of player, like gun, overlaps with car.

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