Making multiple "Cars"?

Get help using Construct 2

Post » Mon Feb 09, 2015 4:30 am

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?
B
9
S
5
Posts: 40
Reputation: 919

Post » Mon Feb 09, 2015 7:46 am

You have to pick the right car with condition beforehand. Can you post capx or picture with code where car entering is managed?
B
12
S
6
G
2
Posts: 99
Reputation: 1,727

Post » Mon Feb 09, 2015 8:19 am

Car.Pick Nearest (Player.X, Player.Y)
B
11
S
4
Posts: 152
Reputation: 1,236

Post » Mon Feb 09, 2015 10:17 am

Message: thedude1693 can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
razorMonkey wrote: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
B
9
S
5
Posts: 40
Reputation: 919

Post » Mon Feb 09, 2015 11:29 am

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.
You do not have the required permissions to view the files attached to this post.
B
12
S
6
G
2
Posts: 99
Reputation: 1,727

Post » Mon Feb 09, 2015 3:30 pm

thedude1693 wrote: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
Image
B
64
S
19
G
67
Posts: 1,310
Reputation: 42,005

Post » Mon Feb 09, 2015 9:09 pm

razorMonkey wrote: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.
B
9
S
5
Posts: 40
Reputation: 919

Post » Mon Feb 09, 2015 9:18 pm

thedude1693 wrote:
razorMonkey wrote: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.
You do not have the required permissions to view the files attached to this post.
B
9
S
5
Posts: 40
Reputation: 919

Post » Mon Feb 09, 2015 9:54 pm

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?
B
12
S
6
G
2
Posts: 99
Reputation: 1,727

Post » Mon Feb 09, 2015 9:56 pm

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.
B
9
S
5
Posts: 40
Reputation: 919

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 9 guests