atmas's Forum Posts

  • You do not have permission to view this post

  • You do not have permission to view this post

  • The "rotate towards angle" action will rotate the object X degrees per tick towards Y angle. Try setting your car.car.steerspeed to a low non-zero value.

    Thank you so much buddy!

  • create family with different instance variable ( for speed and torque ) and then make a dummy sprite...

    Check this link on the forum about using LOS with family :

    https://www.scirra.com/forum/solved-how-do-i-use-los-with-family-of-same-objects_t125867

    Thanks for the help!!!

  • Hi folks! I got a car which has all the frames of vehicles i'll be using in my game. But some of them are trucks, which has different physics, speed, tork than a passanger car for example. So how to i do to make every vehicle singles with their own settings if they are just different frames? I want to import every vehicle individually, but i cannot do this, otherwise, the LOS behavious won't work when workinjg with families. What can i do? Thanks!

  • Here is one way:

    Make an invisible tilemap (green area) as on this picture:

    Tilemap should not be solid.

    For Car in pathfinding properties set Obstacles:Custom and in evens add that green tilemap as an obstacle.

    But if you have lots of cars moving in different directions, this trick will not work.

    You might need to use some other method instead of pathfinding.

    Hi man and thanks for the help. It's a great idea! But as you said, that's the true, i want to create a AI traffic system just like GTA1 Top down. I never fund a post that talks exactly about that. I found some .capx, but they didn't helped much. i thought for once i could build up a traffic system using pathfinding, but as i tried in many ways before, it won't be possible for various cars, right? Thanks anyway.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi folks; how are you? I got i huge dobt that is consuming for at least one year.

    First; i made a (T ) street surrounded by walls; which is solid. Each hand of the street has its angles place accordly to its direction. For example; the left hand; has its angle set to south; and the right hand has its angle to south; so it would make possible to the car follow a path without invading the wrong way. I placed a car on right side of this T street. It must go to a second vehicle that is on botton of the T street. It does it very well; but the car ignores the right hand and just invafe the wrong way to reach its objective. How can i do to fix it? Thanks! Then ill post some prints of what im saying if you like.

  • First of all, thanks for this detail. You even color coded your explanations, it was very nice

    If there is only 1 type of car object, the family is useless. Using multiple instances of the same object type is normal and doesn't require a family. A family would be useful for having cars, trucks, and other vehicle types that share some properties, but may differ in some points. That doesn't change your problem, but I thought I'd say it just in case.

    Your problem here seems to be the selection of both cars, yep.

    The LoS detection will need a loop on each car that you want to analyse, so a "For each car" or "For each Vehicule_Group". You will also want to filter the cars, to only check cars that need checking. For example, a test on the "car_ID" variable you want to set.

    Once you do that, even without the check on the variable, all your cars should stop when they first see another car, so your game should stop quite fast.

    Second problem will be to set the variable correctly, to be able to have 2 different entities in the action. The easiest way is to create a new family containing all the vehicles from the first family, but with nothing else. This family is only here for being able to manipulate both vehicles independently. Let's call this new Family "LoS_Target".

    So at this point, the trigger of your action should be :

    • For Each Vehicle_Group
    • Vehicle_Group.car_ID = 0 // so if we already set the variable, we don't do the detection action again
    • Vehicle_Group Has LoS to LoS_Target

    I'll add some propositions to that :

    • LoS_Target.UID < Vehicle_Group.UID // this will prevent that 2 vehicle check each other. The first will check the second, but not the other way. It depends on what you want to do but it can be useful sometimes
    • Vehicle_Group.UID =/= LoS_Target.UID // this is redondant if you did use my first proposition, but is essential if not, as it will prevent a car from detecting itself. I'm not sure if this is integrated in the behavior by default, so I always add it to be sure.

    Now, in the action, we can manipulate both objects as we wish. For example :

    • Vehicle_Group.car_ID = LoS_Target.UID // we set the variable as you described.
    • Vehicle_Group.AI_var_SPEED = LoS_Target.Car.Speed // or something close to that, I didn't reproduce your code

    Be aware that LoS check are costly if done too much, don't overdo it if useless.

    Thanks for your patience to read everything and help me again. And i'm very happy that you understood what i meant. For me, is not so easy because what i want as you saw, it's very specific details. There's a lot of tutorials out there, but 1% explains exactly what we want. Thanks to you and another users, i'm progressing well in this. I'll try to do everything again and see what will going to happen. Bye!

  • Maybe a screenshot of the events where you do the detection could help to understand your problem. It can depend on how you built your game. For example, it seems each car is a different object type from what you are saying, and that you collected them in a family. If so, then the picking should be a double condition, car in line of sight of car, car.UID =/= self.UID

    It's hard to know where you made your error. What is sure though, is that an object can detect another object on the same layer, this has no reason to interfeer.

    You say you detect the player's car correctly, but it's another object type, so the logic may not be in the same event (it shouldn't be at least). So yeah, a screen cap maybe ? ^^ or a sample capx where you can reproduce the same behaviour with the fewer objects possible, a unit-test around your problem, will help us help you

    Hi! But the cars are the same objects in the family group. That's why maybe i'm not doing the things right. I created a mini city to test the AI cars spawning on streets and try to make them detect each other. In this layout, i just have one single type of vehicle. Then i copies and pasted some of them. And the codes make them drive on street randomly. I'm know that, the code to pick the nearest car and compare it's distance between the (AI car) that is behind, we use the following: ''SISTEM> COMPARE TWO VALUES> if distance(car.x,car.y,car.x,car.y)> then.... (what to do)... '' And we should set to the 'family group'' a variable with a name like: ''carfamily.id''. And in it, we will save what's is the UID of the nearest (AI car) that is in Line of Sight of the AI car that is coming from behind. But i really don't know how to create this system right. I guess i inserted wrong number or even all this code i wrote above is wrong. And just to let it clear, i really don't know how to use the ''UID'' AS A id of a object properly. It get worst for me now, because we're talking about of an object that will have to detect the same object as itself. Sorry if my english is not so good and i would aprecciate if you correct me. I'll let a print screen of my scheme below.

    The cars that are the same object, has the following things enabled:

    • Colisions on
    • Line of Sight: 180° Range: 200 distance

    1- http://i67.tinypic.com/fabwnm.png

    2-http://i65.tinypic.com/2zhecrp.png

  • atmas here is version 2 with the expression i was talking about the manual alternative to notequal is "<>" so its kinda of working however there's plenty inside there that i hope you will understand i didn't spent any time to comment it. if you need that let me know. dont mind the LOS behavior is still attached but not used, i only used pathfinder to make the objects move towards some direction and some extra identifiers with their own identifiers as instance variables, there is a 40 pixel jump backwards when they see the collision which makes them get out the field of view and then reenables the points hope you can adapt any of this to your project and possible solves your problem. .... even this since is not perfected and done in a rush still fails some times.

    the extra red dot might not be needed, and you could actually pick the same AI using distance by comparing " <>" UIDS of objects. that i will definetly do in morning. Good night!

    Hi gamescorpstudio, i'm trying to solve this problem out since morning here.

    I'm sure your example i'll help me a lot! Thanks again man and have a good night!

  • Probably some issue with picking, probably picking itself since a car is trying to detect a car. When the car is detecting if it is in sight of the player the picking logic is much easier, to determine whether a car can see a car you may have to add in some variables or IDs to ensure that it is not picking itself and that it is not applying the logic to all cars when one is in LOS.

    Hey! In my game, there''s a family where all the cars are in it. And i'm using a code tat spawn randon cars on street from the same family. And that's why i'm using the code ''from car to car from the same type'' and etc. But thank you man, i'll try to create something that makes sense.

  • > I tried to use the L.O.S behaviour, so each AI car would know each other and would avoid crashing one into another, but this won't work. I'm saying that because when i use the L.O.S behaviour in the AI cars to detect the player that is in another layer above, it works 100%. What can i do to fix this? Thank you man!!!

    >

    L.O.S is line of sight which basically uses some sort of distance(x1,y1,x2,y2) but most of times it breaks when used with pathfinder together, so my advice would be to drop L.O.S and use the expression " if distance(car.x,car.y,car.x,car.y) less or equal then 100 car stop (at this point you made your own L.O.S without the behavior and without the problems of L.O.S and Pathfinding behaviors). now i know it might seem obfuscating from our point of reading the code, but C2 actually has a background system that when you appoint the car.x, same time, basically what does, for each car that detects another instance of the same car object it applies that. you might need to add for each loop while using it. but should work, i used it on a aquarium type of game and AI ( AI used same name no numbers picking or other tricks just pure "aifish" for all different types of fishes.)worked awesome they were hunting each other and the player no confusion whatsoever in code. so that being said, i think it might work for you also. Hope you can understand my spaghetti code from above and the explanation.

    Edited: ehm.... i forgot i did used a identifier i used their frames numbers. but i dont think that would help in your case let me check something il get back to you.

    Hey man, thanks for your attention! A lot of people are helping me, and for me, it's very important, because i'm learning all the codes by myself and almost getting nut because of some little issues hahaha. I understood 100% of your explanation! I'll try it now. I was trying some combinations hours ago to find the right way to write that same code you told me. I was trying to use the ''SYSTEM> COMPARE TWO VALUES'', but with wrong logic. If it work for me, i'll reply here. Thanks!

  • atmas why use overlapping points for a pretty intensive graphic game? i would've used "distance again" (i know dop2000 ) because its less heavy on systems logic. using overlapping points of images the computer or system has to measure each pixel in each frame and see if they are colliding. you could use bbox left right top bottom of the car and target imagepoint.x,y and measure the distance if distance is a surtain safety number car stops. you will notice with this approach a 50% to 90% cpu usage drop, depending on your project how heavy is from graphic point of view.

    Hello, how are you? I simplified this problem by creating some stop signs before the intersection, so the AI car now stops on the line for some time and then, he start moving again. Could you help me with another issue please? It's

    the following: AI cars that are on the same layer, won't detect each other. I tried to use the L.O.S behaviour, so each AI car would know each other and would avoid crashing one into another, but this won't work. I'm saying that because when i use the L.O.S behaviour in the AI cars to detect the player that is in another layer above, it works 100%. What can i do to fix this? Thank you man!!!

  • Hi folks! I got a problem that i really don't know how to solve it. Can you help me please? AI cars that are on the same layer, won't detect each other. I tried to use the L.O.S behaviour, so each AI car would know each other and would avoid crashing one into another, but this won't work. I'm saying that because when i use the L.O.S behaviour in the AI cars to detect the player that is in another layer above, it works 100%. What can i do to fix this? Thank you!!!

  • Hello! How are you? After sucessfully create random vehicles on street of my test city, i would like to make them to stop on some image points of my intersection for some seconds, but this is not working. I really not good with expressions, but i was trying to guess what to write to make it work properly. Please, take a look on my images below:

    PS: (In the IMG Nº1, each of the 4 ''Parameters for ''inter'' codes, there's a different number for the ''inter'' imagepointX and Y.)

    1-

    2-

    Question 1: As my codes are not right, what should i do to make it work?

    Question 2: How can i make the cars that come from behind to stop and avoid hitting the car in front? Because i tried a lot of codes using ''Line of sight behaviour'', but they still hitting the others AI cars on intersections and etc.. The L.O.S behaviour only works if i set them stop when they has the player on his line of sight.

    Thank you in advance!