mekonbekon's Recent Forum Activity

  • Maybe this would work:

    On function "changedTouched"

    Square is playing animation "small": Action: Square play animation "newanimation"

    Do you have a capx you can share?

  • Hi justifun - I know you've got a solution from 99Instances2Go , but this problem stuck in my brain and I couldn't let it go, so here's one I came up with:

    https://www.dropbox.com/s/viwoutpz4by0g ... .capx?dl=0

    I haven't been able to view 99Instances2Go 's as it's done in a later version of C2 - so apologies if it's the same.

  • PixelByPixel

    Had to fiddle around with the events a bit (the check for loops not equalling zero was broken, but this works:

    https://www.dropbox.com/s/jim9fwrlhqtbf ... .capx?dl=0

  • PixelByPixel

    Hi there, you need to use Pick Overlapping Point, not Pick by Evaluate.

    And also your local variables should only be referencing the starting object, i.e. the object in the middle - you don't need to pick all.

  • sbz For future reference, seeing as you've already found a solution

    The first line would be using the System|Compare two values condition, and you'd fill the fields in as follows:

    First value: distance(player.X,player.Y,object.X,object.Y)

    Comparison: less than

    Second value: 4 (for example)

    Hope that makes more sense.

  • Make sure you're not playing the sound every tick - use a "trigger once", for example.

  • Hi Trimeister No worries

    To make NOT you invert the condition: right click on the condition and select the "invert" option; it should add a big red cross to the condition. This is very useful for lots of conditions, so bear it in mind for the future.

    For the angle you need to use the "angle" expression: select the "within angle" condition and in the angle field write "angle(enemy.X, enemy.Y, object1.X, object1.Y)". This provides you with the angle between two objects.

    If that doesn't work give us a shout.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • FabianB

    Glad to be of help

  • The wait 2 seconds will trigger every tick as well, so after two seconds it will start trying to turn to object 2, but at the same time it's still trying every tick to turn to object 1 so it will remain facing object 1.

    I'm guessing what you would like it to do is rotate to object 1, wait 2 seconds and then rotate to object 2?

    If so, this should work:

    Add an instance variable to the enemy called "target"; set it to 1.

    Add a timer behaviour to the enemy.

    Add this code to your event sheet:

    Event: enemy| instance variable "target" = 1

    Sub-event: enemy| NOT is within angle 2 of angle(enemy.X, enemy.Y, object1.X, object1.Y): Action: enemy| rotate 2 degrees towards (object1.X,object1.Y)

    Sub-event: enemy| is within angle 2 of angle(enemy.X, enemy.Y, object1.X, object1.Y): Action: enemy | set timer "wait" to 2 seconds

    Action: enemy | set instance variable "target" = 0

    Event: Enemy| On timer "wait": set instance variable "target" = 2

    Event: enemy| instance variable "target" = 2

    Sub-event: enemy| NOT is within angle 2 of angle(enemy.X, enemy.Y, object2.X, object2.Y): Action: enemy| rotate 2 degrees towards (object2.X,object2.Y)

    Hope that helps

  • Do you mean each enemy has it's own health bar, for example over its own head?

    If so, create a sprite called "healthbar" Add the pin behaviour to it. Add an instance variable called initialWidth and set it to the starting width you want for the healthbar.

    Add it to a container with the enemy; when an enemy is created it will automatically create a healthbar object. Give the enemy "health" and "healthMax" instance variables - set both of these to the max health of the enemy.

    Add this code:

    On enemy created: Set healthbar position to (enemyX, enemyY-(enough pixels so that it appears above the enemy's head))

    Pin healthbar to enemy.

    When an enemy takes damage you want to reduce the width of the health bar, e.g.:

    If enemy collides with bullet: enemy|subtract 1 from health

    healthbar set width to healthbar.initialWidth*(enemy.health)/(enemy.healthMax)

    Because the healthbar is in a container with the enemy, only the healthbar for that enemy will be affected.

  • Building on 's answer:

    Create a sprite, call it spawner.

    Add the rotate behaviour to it and give it a value

    Add the timer behaviour.

    Add an instance variable "shoot" to the spawner and give a value for how often you want the spawner to shoot a bullet.

    Create another sprite, call it bullet. Add the bullet behaviour to it.

    Add the following code to your event sheet:

    On (choose a trigger) set timer "shoot" to spawner.shoot (continuous)

    On timer "shoot" : spawner| create bullet;

    bullet|set bullet angle of motion to spawner; (make sure you use the bullet behaviour action here)

    On (choose a trigger): stop timer "shoot".

    You can then adjust the spawner rotate speed & direction and shoot variable, and the bullet speed to vary the pattern.

    Use whatever triggers you want to start and stop the spawner.

    For some variety try adding the sine behaviour to the spawner and use the angle, vertical or horizontal settings to move the spawner. Remember to remove/stop the rotate behaviour before doing this or things might go a bit weird - or maybe that's what you're after!

  • Hard to say without seeing a capx, but I would suggest having a play around with the density, friction and elasticity; probably the last one would be best to adjust first - try setting it to 0 and see what happens.

    Also reduce the number of blocks you are using to 2 or 3 - check whether you get the same issue with a small number first, fix that and then scale up.

mekonbekon's avatar

mekonbekon

Early Adopter

Member since 9 May, 2014

Twitter
mekonbekon has 13 followers

Trophy Case

  • 10-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • x2
    Popular Game One of your games has over 1,000 players
  • Famous Game One of your games has over 10,000 players
  • Coach One of your tutorials has over 1,000 readers
  • RTFM Read the fabulous manual
  • Great Comment One of your comments gets 3 upvotes
  • Email Verified

Progress

18/44
How to earn trophies