How do I fix issue when I change the size it breaks some event blocks?

Not favoritedFavorited Favorited 0 favourites
  • 5 posts
From the Asset Store
Very simple code without excess options (15 events for server and 11 events for client)
  • I'm having a problem with a game I'm making and wondering what I'm doing wrong! Basically it's a fish-eating game, the player is the orange fish and needs to eat blue fish that are smaller in size which also regenerate! This all works fine except when I set the size of the blue fish in the event sheet, it appears to break other events, such as the sprite doesn't flip the correct direction anymore and doesn't compare the size of the fish so can basically eat anything!

    Can anyone point me in the right direction of what I am doing wrong here!?

    I've made the following video which probably explains it better:

    I've tried setting the size using the scale and also when it is off-screen but however I change the size of the blue fish, the same problem occurs!

  • You forgot the video :)

    Anyway, to get help It's better to share your project if you can, so people can take a look at what you are trying to do.

  • Oops! Here's the video:

    youtu.be/_bby9XRLevA

    And a link to the file: drive.google.com/file/d/16wgGsysDRO1DiaGQoAZv-7AgLAN7i6lR/view

  • You have two problems, the first one is the call to random.

    It looks like this

    	random(0.2-1.5)
    

    The problem with that is that it's generating a random number between 0 and -1.3.

    I think you were trying to do this instead

    	random(0.2, 1.5)
    

    To generate a random number between 0.2 and 1.5.

    The second problem is a little bit more subtle. When you flip (or mirror) a Sprite, Construct is inverting that size. Ej. A width of 50 when flipped becomes -50.

    If you then do any calculation assuming a width or height is positive, then it's not going to work.

    In your case the Compare Width check you are doing only works as long as the width is positive.

    To do the proper calculation, you need to make sure you are always performing that check with a positive value. Instead of using Compare Width which doesn't let you manipulate the width, you can use the System condition Pick by evaluate to have a little bit more control on what is going on.

    Use that condition, choose the object you want to pick and then use this as the expression to evaluate.

    abs(foodFish.Width) < fish.Width - 20
    

    That is pretty much the same you are already doing, but it takes care of converting foodFish.Width to an absolute value before comparing it to fish.Width.

    With that condition it doesn't matter which size the foodFish has, it will always work.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Awesome thank you so much for the help! That all makes a lot of sense. It's really good to know that about the size in particular!

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