Same functions on same sprite copies

Get help using Construct 2

Post » Mon Feb 24, 2014 1:05 pm

Hello guys!

I'm new to C2 and i think that C2 is a great experience :).
But i have a problem :(.

First of all i'm trying to create GTA 2 prototype and i'm creating cars ,but C2 only checks for one UID , so how can i check or assign UIDS?

Here is my project https://www.dropbox.com/s/gkqhnmkktbybz2l/gta.capx

I don't really know how to explain this , but testing would get my idea.
B
3
Posts: 8
Reputation: 196

Post » Mon Feb 24, 2014 1:21 pm

This is caused by your event number 7 (and/or 13, same script for both cars) where you active the controls of the car, but don't select a car first. You need to pick the car in the conditions first if you want to act on this car, or else you will act on every car.
For this, as you choose the car by calculating a distance, you need a foreach condition.
Here is what those events would look like.
B
17
S
8
G
4
Posts: 473
Reputation: 6,211

Post » Mon Feb 24, 2014 1:28 pm

Now when i enter a car it gets to the original sprite and all sprite copies are moving with the original.
B
3
Posts: 8
Reputation: 196

Post » Mon Feb 24, 2014 1:39 pm

What do you mean by "it gets to the original sprite" ?
All cars were moving yes, that is the problem. The changes I suggested should still comport other bugs, like the fact that you can enter 2 cars at a time if you are near both. If you want to do it properly, use functions and UID, like this. (this is a corrected example. I deactivated car2 group for testing purposes, used UID and functions, and it works nicely)
B
17
S
8
G
4
Posts: 473
Reputation: 6,211

Post » Mon Feb 24, 2014 1:55 pm

Thanks it works fine but now there is problem with scroll to behavior :And it's really hard to understand what you did there...
B
3
Posts: 8
Reputation: 196

Post » Mon Feb 24, 2014 2:04 pm

What did I do... I tried to structure the code a little more, using sub-events (events inside of each others).
The E key pressed will start an event where, depending on the state of the game (is the player inside the car ?), it will do different things.
- if the player is out of a car, the game tries to find a car near the player. The first one found will put the player inside it by calling a function, and passing it the car.UID. This way, only this car will be activated, as the function starts by selecting only this car (Car.SelectByUID, event 9)
- if the player is in the car, we just get out of it, disabling every car's movement and enabling the player to move.

The only difference with the screen capture from before is the "Stop loop" I added on event 8, as it will stop as soon as a car is found near the player.
The functions are here to make it clearer.

Well, I didn't handle the scroll as your problem was with the car selection/activation... If the scroll is on the player, then you should "Pin" the player to the car he is in. Right now, you put the player in the car, then drive the car, but the player stays in place. Use the pin behavior, activate it in the getInCar function after putting the player inside the car, and deactivate it in the getOutofCar function
B
17
S
8
G
4
Posts: 473
Reputation: 6,211

Post » Mon Feb 24, 2014 2:16 pm

Thanks.I will try the pin behavior.And i found another bug : the set position to car imagepoint 1 is not working...
B
3
Posts: 8
Reputation: 196


Return to How do I....?

Who is online

Users browsing this forum: jogindarpradeep, matriax and 17 guests