Same functions on same sprite copies

0 favourites
  • 7 posts
From the Asset Store
A set of 10 pixel art animated magic effects with icons. 2 Fire, 2 Earth, 2 Wind, 2 Water, Portal, Explosion.
  • Hello guys!

    I'm new to C2 and i think that C2 is a great experience <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">.

    But i have a problem <img src="{SMILIES_PATH}/icon_e_sad.gif" alt=":(" title="Sad">.

    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.

  • 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.

  • Now when i enter a car it gets to the original sprite and all sprite copies are moving with the original.

  • 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)

  • Thanks it works fine but now there is problem with scroll to behavior :And it's really hard to understand what you did there...

  • 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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks.I will try the pin behavior.And i found another bug : the set position to car imagepoint 1 is not working...

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