Guizmus's Recent Forum Activity

  • It would be strange that it would have not been reported, but maybe... Did you try preloading the image in a sprite you don't show, prior to loading for your real object ?

  • There is also a system condition 'Pick nearest instance'. You can use this to pick the nearest instance of Y to X and aim at it. Some calculations with distance are good to know though.

    Well... That is a lot simplier then... Lol sorry for the convoluted solution when there was an obvious one.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • And the exported app is running on your phone ? Do you have access to localhost on your phone, by being on the same wifi ? You may need to host it online if you want to do it like that, localhost is local. I may have missed something obvious though, sorry if I did

  • marcinkowski

    Maybe this little thing I just made could help :

  • If it only affects the exported version, it may be because the image you are linking to is redirected. Your computer and the phone may handle the redirection differently. When you open the image in your browser, do you get redirected to another URL? Does the "copy image link" gives you anything differently ?

    In some rare cases, the website can block loading outside of specific useragent too, but this is not common at all.

  • But coins should always swap his position every 32pixels after create

    What do you mean ? I don't understand you. Where do you want to move your coin ? Swap it with what ? The sprite ? What happens when there is multiple coins, do they all swap wit the sprite ?

  • Something like this :

  • Hey !

    Be aware that doing this by only checking random coordinates can be very long if the map is full or nearly full of bases. You can even make an infinite loop here.

    That being said, the problem in the events is that you take 1 set of random coordinates per cycle of the main loop. So in total, you take maximum NrOfBases coordinates, even if one random set is valid or not.

    The second problem is that, if it find any base that is further enough, then it decides that it is a valid position. Instead, it should be only if ALL bases are further enough.

    So you need to change the base loop here, by making it a while instead of a for, and by modifying you "validation" detection. The easiest should be to do something like this :

    EDIT ! I forgot the While in the main loop....

  • The we need 2 consecutive actions, that you want to execute every time you need the player to switch target. It could be every 1 second, but maybe don't check this every tick, it could cost a lot if you have a high number of enemies.

    First action will check all enemies, and set a variable to remember what enemy is the closest. Let's call "EnemyID" (set to 0) and "EnemyDistance" (set to 1000000 to make this easier) the 2 variables :

    • For each object Y // we want to do this test for every enemy
    • EnemyDistance > distance(ObjectY,Player) // if the enemy we are checking is closer to the player than another before

    This will trigger a simple action that will set both variables, EnemyID to objectY.ID, and EnemyDistance to distance(objectY,Player).

    Once this loop is done, the variable "EnemyID" is set to the ID of the enemy that is the closest to the player. You can create a second action, that will select the enemy by it's ID using the variable, and ask the player to take it as target.

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

  • 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

  • I would start by checking the content of config.xml in the exported app, as the message states. It seems it put the errors there, and knowing what is wrong would surely help to solve it

Guizmus's avatar

Guizmus

Member since 26 Mar, 2013

None one is following Guizmus yet!

Trophy Case

  • 11-Year Club
  • x4
    Coach One of your tutorials has over 1,000 readers
  • Educator One of your tutorials has over 10,000 readers
  • RTFM Read the fabulous manual
  • Email Verified

Progress

15/44
How to earn trophies