dop2000's Forum Posts

  • I don't understand why the family solution is not working for you. If you disable all other events you can see that it works fine:

    In this case the "Is overlapping" condition picks two instances - one Sprite1 and one Family. This allows to compare their frames.

    However, if more than two instances are overlapping, the event may not work. You will need to do more picking to select two specific instances for comparing.

  • Here is an example, but it may not be suited for your purpose because Physics is disabled during dragging. Which means that the object will not collide with other physics objects while you drag it.

    howtoconstructdemos.com/throw-a-physics-object

  • Press F12 in the preview window and check for errors in the console log.

  • It's still not working, What I'm doing wrong?

    You are not picking the right instances.

    Before you do anything with instances in Construct you need to pick them. Otherwise the engine doesn't know which instances you need. Imagine you have 1000 instances of Sprite1. Which ones the engine should select to compare their animation frames? Which ones should become visible?

    Picking is possibly the most important concept in Construct. I suggest you start by reading the official documentation and studying some tutorials.

    .

    The result showed that construct3 has a problem with comparing objects to themselves.

    igortyhon I don't see any problem in your example. The condition "Sprite1.AnimationFrame=Sprite1.AnimationFrame" is always true, which is expected.

  • anglediff but not sure how it will work when one value becomes negative

    Anglediff will work just fine.

    You can convert an angle to positive number using this formula: (angle+360)%360

    The result will be between 0 and 360. But I still recommend using special System conditions which are designed for working with angles.

  • suppose if I want to check whether both values are 185 or not. selfangle will show 185 but angletoplayer will show negative value when its supposed to be 185

    This is not a good idea, because the angle may not be exactly 185 degrees, it may be 184.999999999998 or something like that. So even if both angles are positive values, I still don't recommend comparing them directly.

    Use System conditions, for example "angleA Is within 0.5 degrees of 185". This will work with any angle values positive or negative, and will account for any rounding errors.

    Another option is to use anglediff expression:

    anglediff(angleA, 185)<0.5

  • With two instances of a sprite, but each instance having different frames.

    You can't compare two instances like that! When you use an object in an expression like that, only the first instance is checked. So you are comparing it with itself.

    If you want to compare two instances, you need to pick each instance separately. With a single object it's tricky, a common workaround is to use a family. Then you pick 1 instance of the sprite and 1 instance of the family, and compare Sprite.animationFrame=Family.animationFrame

    Another option is to use IIDs:

    Sprite(0).animationFrame=Sprite(1).animationFrame

    But you need to be sure that there are only two instances on the layout.

  • Use an instance variable - once the sprite is spawned, set a value in the variable. Check that this value is not set before spawning.

    Another option is to add the child sprite to a hierarchy. Check that the parent sprite has no children before spawning.

  • but after 180 angletoplayer variable becomes negative

    It doesn't matter if you use special conditions which deal with angles - like "Is between angles", "Is within angle".

    Also, you should use delta-time if you need to rotate or move characters with events. Replace "rotate 1 degrees" with "rotate 60*dt" degrees.

  • You can use angle() expression and "Is within angle" condition.

    For each enemy
    System enemy.angle is within 20 degrees from angle(enemy.x, enemy.y, player.x, player.y)
    ... Enemy spawn bullet
    
  • but now one time.

    I don't understand what you mean.

  • There is no bug, you just need to configure all settings properly.

  • Because it doesn't work per instance. If var=2 condition is true for one instance, the event will run once for it. But if var becomes 2 for another instance, the event will not run again, because it has been triggered once already.

    Like I said, it's a very common mistake, I've seen it so many times. Scirra devs really should've explained it better in the documentation.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Don't use "Trigger once" when multiple instances are involved. It's a very common mistake, which can cause all kinds of bugs.

    Simply put the "find path back home" action after 3 seconds wait.

    Enemy on arrived
    pathtype=1 
    ... Wait 3 seconds
    ... Enemy set pathtype to 2
    ... Enemy find path to home
    

    Or, better yet, use Timer behavior instead of Wait.

  • Try making the preview window larger. When it's smaller than the Viewport Size specified in project properties, all graphics is scaled down. When 1px lines are scaled down, they will always be distorted.

    Try these settings, they work for me: