TheInstance's Recent Forum Activity

  • smile

  • OK.

    Allow me to repeat the targets

    [quote:2fzyxecm]I want the smiley's to fall by Gravity.

    When they are falling i want them to smile.

    When they are climbing i want to them to "ohhhhh!".

    When they bounce i want them to stick out there tongues.

    I want them to bounce on a ground, and during the bounce to act more as plastic balls, including seizing there shapes a bit, and getting a little jump up.

    Everything that i want to do is related to what the objects are doing in the Y direction.

    (yes i had a reason to simplify this)

    But, we lack support for conditions related to the physics behavior. There is no condition that goes like "on object falling". There is no "compare xxxxx" condition to pick 1 of the instances based on one of the behaviors properties.

    But.

    I know that i can read out the Y velocity component in the behaviors expressions.

    I just do not know yet what values this expression has in certain situations.

    Lets set up a sorta kinda laboratory to watch the Y velocity change, and make conclusions.

    But, since we deal with instances, and those instances fall from a different hight. I have this suspicion that the Y component will be different for each object.

    Yet we have no pick condition to isolate an object and retrieve its expressions for the Physics behavior.

    Oh do not worry, the solution is pretty simple. Look at this .cap

    In the layout you see 3 text boxes. 1 for each object to write there Y velocity components in.

    I know that i made the objects from the left to the right. Due this, a "For each loop" will walk trough the instances from the left to the right. We have the excellent pick condition "compare private variable". So all we need to do is loop trough the instances with the "for each object" loop, set a private variable to the Y velocity component. And now we can pick instances based on that private variable. In other words: we convert the flow condition, that we could make by comparing to an expression, to a usable pick condition, by storing the expression in a private variable and pick that object based on the private variable. Elegant ? no ?

    But, i am not that far yet. I still do not know what this Y component looks like. What values is it holding in witch situations ?

    So i made this lab to see what it all is about. Look at the events.

    Using the For Each loop, i walk trough the instances (in event nr 3) from the left to the right. If the loop counter = 1, then the first instance is picked. And i fill its Y velocity component into the first text box (event nr 4). Same for the other 2 objects.

    Then because i dont like to hit "run all" over and over, i made a little loop. (recalling the layout made me crash). So in event nr 7 i use the same for each loop every 7 seconds. I place each object at different heights. And i give it a down force to bring them out of rest.

    Now i can watch the objects. And figure out what exactly that Y component is standing for, and what values it actually is holding.

    Now when i ran this Cap for the first time, the Y component had floating numbers, and to be honest that did not tell me much. Especially because very small numbers show as a bunch of numbers with an e at the end. Its impossible to recognize a zero, or any number for that matter. To overcome this, i rounded the numbers, as you can see in the actions that write in the text boxes.

    Now.

    Run the Cap. And watch yourself. Make conclusions.

  • Try Construct 3

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

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

  • Download this and fire it up.

    Look at the layout.

    I only added Box objects all around the layout.

    You would expect that i made the box objects solid. But nope, not needed for physics to work.

    BUT, i gave also the Box objects a physics behavior. And made them immovable in there physics properties.

    And thats all to set up a closed Physics world. Glance at the events editor, no events !, no programming. (look moms no hands)

    Yet, Run all ..

    And .. admit that this is actual a very nice simulation.

    But now, to make you understand that it indeed is a box in a box.

    Go to the events editor...

    Add an event from the system condition "Every milliseconds".

    Give it a value 7, witch is each 7 seconds

    Give that event an action, setting the smiley objects Y at 100.

    So every 7 seconds the objects jump to Y = 100.

    Run all.

    The first time the objects fall as expected.

    The second time they dont fall at all.

    They are physical dead. Well all there potential energy and there velocity's came to rest while bouncing of the ground and returning to the ground.

    Physical they came to a rest point.

    And moving them by an event, just setting there Y's is NOT interacting with the physics world.

    Plz keep that in mind !

  • The Physics world is a box in the box. Its not aware about the events. And the events are not much aware of the physics world. I will post a .cap a little later to prove that statement.

    To make things work, we will have to talk straight to the Physics world in our events. To make decisions we will need to retrieve info from the Physics world.

    We do this by accessing certain properties of the Physics world, and use them in expressions.

    So lets explore the possible properties we can use in expressions.

    Still with the same .cap. With Physics added to a smiley object. Go to the events editor.

    Add an event, starting from the system object, choose 'compare' as condition.

    In the next wizard step, the one with the parameters ...

    Click in the value 1 field.

    Double click the smiley object on the bottom of the wizard ...

    Click on the Physics tab, where it says "select expression"

    Now you have all expressions listed for the Physics world attached to the smiley object.

    And that is not that much.

    1/ Get mass

    In the real world the mass of an object will change with its speed. I have not tested yet if this is the case in construct too. But so yes, we have to be able to get the mass of an object.

    2/ Get linear damping.

    Does what it says.

    3/4/ Get world X and Y scale, plz post a comment to explain those to me.

    5/ Get velocity X component.

    Yes! We can retrieve the result of all the forces that we added to an object. And combined with the Y velocity component, we can know the objects ...

    Speed ..

    Direction its moving ..

    If its moving at all ..

    Is it speeding up ?

    Is it slowing down ?

    Those are the base components for all math behind objects moved by physics.

    6/ Get velocity Y component.

    7 Get angular component.

    To know if ...

    the object is rotating ..

    the speed its rotating ..

    the direction that it is rotating

    and more

    Thats all ?

    Well thats a BIG world of information. And once you start to work with them, you will know that there is not much more needed to know.

    Ok back to our target.

    Delete all events.

    Back to the layout editor ...

    The smileys should have a physics behavior.

    Just check the gravity switch in the behaviors properties ...

    and ...

    Run all.

    As You see ...

    They start falling. They do not fall instantly. They start falling and build up speed as they should and would do in the real world.

    And they keep falling and falling.

    Its a Physics simulation world.

    And i happen to like it.

    So lets add a ground to make them bounce off from. Where i start next post.

  • Or use groups, they have a comments field. And can be set active or inactive.

    Or, use the "always" condition to start event trees, and set the condition inverted to exclude it from running.

  • Right, so still with the same .cap. Name one of the smileys to anything you like.

    Go to the Events editor.

    Add an event to the empty sheet.

    Start from the smiley object.

    In the next step of the wizard, where you are supposed to choose a condition ..

    Notice the object has 2 tabs on top.

    Its own tab and a tab called Physics.

    Click the Physics tab.

    Wah ? no conditions for the Physics behavior ? Ah yes sir. In the present release the Physics still lack conditions. This will be something we will have to work around. And oh we will. Do not worry.

    Maybe in a next release there will be conditions added.

    Possible conditions could be:

    On 'object' is moving.

    On 'object' bounce.

    On 'object' at turn point.

    On 'object' slowing down

    on 'object' speeding up.

    Compare 'objects" X velocity

    Compare 'objects" Y velocity

    But for now, no conditions. We will counter this.

    So add a system event from the system condition "always". To explore the actions.

    Add an action to this. Start from the smiley object. Click on the physics Tab.

    Yes sir ! There are a bunch of actions here.

    Lets walk trough them.

    1/ Add force.

    Imagine a paper airplane passing you. And you give it a little slam to make it fly faster. Thats what 'Add force' is meant for. The paper plane was moving already due a force given by some one else earlier, and you add your own force to it. Now slamming that airplane makes it move according the angle that you slammed it. Slam it with your hand moving from down to up, will cause the plane to move upwards. This is why Force has 2 values, X and Y component. When you add a force, you will have to figure out the X and Y component of this force. X and Y components relate to each other as cos and sin. but that is for later.

    2/

    Set force.

    Imagine you catch that paper airplane. And trow it yourself by your own force. In other words, take away the force that the paper plane already had, and change it to only your force = set force

    3/ Add force towards a position.

    Read: add a force to an object so, that when the object on the moment that you add this force and it was not moving by any other forces, it will move to the given position. Simply said: Add a force to a non moving object and as result it moves to the given position. Of course, since you "add", this new force, it will add to the forces that make the object already move, so its not sure that it will move towards the given position as result.

    lets say, there is a car passing you. And you give it by hand a force towards the middle of the road (position). The car will hardly change direction, since the forces that move it already, added with your force to push it to the middle do not change much at the global situation.

    4/ Set force towards position.

    Take all the possible forces from an object and add a new force resulting in the object moving to the given position. Or: Stop the object, then move it towards the given position by the given force.

    Or: Stop the car and push it to the given direction.

    5/ Create Hinge to position.

    Make the object glue to a certain position, with a given Stiffness.

    Like lets say. A door hanging in its hinges. When you slam the door, it will try to keep its position to the hinges. Hinge to a position is like hinging the object to an immovable object.

    6/ Create Hinge to object.

    Same as 5 but to an object, lets say a door to a wall.

    When you slam the door with a big force: the hinges will break. And an even bigger force will hang the wall at the door while both move into space.

    Also, when the door has way more mass then the walls, the door will move the walls.

    7/Set Gravity enabled.

    On or off for this object.

    8/Set mass.

    Make the object lighter or more heavy.

    9/Set linear damping.

    Damp the accelerations in the moving forces.

    10/ Set Force of gravity.

    9,8 on earth.

    11/ Add torque.

    Ok, we had force.

    When you hit a ball, you add a force to it.

    When you balance the ball on the tip of one of your fingers, and give it a little push to rotate it, you add torque to it.

    When the ball was already rotating on that moment, your torque will be added to the forces (torque) that made it rotate already.

    12/ Set torque.

    Thats like stopping the rotation of the ball and give it a new rotation.

    Or:

    Take away any torque off the object, and give it a totally new torque.

    13/Set torque towards object.

    Well see it as. When you sit with 2 people at a table. Lay a pencil on the table. Point it to yourself. And give it a little push so it rotates towards the other person.

    Or: take all torque of an object, give it a new torque, with as result that the object will rotate from the current angle towards the given angle.

    Of course, if you give it a big torque, it will take less time to reach the given angel.

    14/ Add torque towards angle.

    Well, suppose you hit the pencil to hard. Its about to rotate more then you intended. Risking to face back to you. And you give it a little push, to correct its rotation towards the other person.

    Thats "add torque towards an angle".

    15 Set velocity.

    Imagine. A car toy in the middle of the room. You give it a push to make it move. Then you disappear from the room.

    I enter the room, and there is no way for me to know what force you used to make the toy move.

    I can not know what torque you used to make it rotate.

    But i see the result. The toy is moving, rotating, accelerating, de-accelerating.

    What i see, the result = the velocity.

    I know when the car is going slower, when i compare its velocity on different moments by eye. When its velocity is less then it was a moment ago, its going slower. If the toy is moving away from me, and i put myself as reference to this world, the velocity will be positive. If the toy is moving towards me, it will be negative.

    Velocity = speed ? Yes and no. When working with physics, objects mostly do not have a constant speed. But yes, if we make the moment that we measure very very small in time, it comes close to measuring speed. So yes velocity gives a good indication for speed. And by comparing velocity measured over moments in time, we can know if the object is slowing down or going faster.

    Velocity, just like force, has a X and Y component. Maybe a little picture is on its place here.

    <img src="http://usera.imagecave.com/j0h/tick/vector.jpg">

    We can set in an action the X and Y velocity components that combined make up the way, the speed, the direction.. the object is moving. Combine negative and positive X and Y components allow us to describe any direction , any speed.

    So we only need to know how to set the velocity and forget about torque and force ?

    No sir. After all a Physics system is meant to simulate real world forces. In the real world you push an object to make it move (add a force to it). The object will start moving depending on its mass, depending on if and how it was moving already, depending on its physics. It will build up speed, and lose speed depending on the damping (linear damping).

    Velocity is cold math. Changing velocity will instantly change the objects movement. Not counting in forces that was already there. Not counting in inertia. That is impossible in the real world.

    16/set angular velocity.

    More of the same to make an object rotate.

    Next post about physic's properties that can be used in an expression.

  • Assume the position. Download this .cap and fire it up.

    What you see are 3 smiley's, close to the shape of a ball.

    All 3 are instances of the same object.

    Select one, and bring up the Animator (on the right with all the other organizers ).

    They have 3 animation states: fall, climb and bounce.

    This is as far as i prepared this position to start from.

    Now what do i want to do ?

    I want the smiley's to fall by Gravity.

    When they are falling i want them to smile.

    When they are climbing i want to them to "ohhhhh!".

    When they bounce i want them to stick out there tongues.

    I want them to bounce on a ground, and during the bounce to act more as plastic balls, including seizing there shapes a bit, and getting a little jump up.

    Ok, thats the project ( i have not done this before, by the way )

    So bring up the objects properties on the left of the layout editor.

    Add the behavior "physics" to one of the balls. And lets walk trough this behavior.

    1/'link'

    __to remove the behavior.

    2/Name

    __ You can change that name. Just dont use spaces plz. A project can have many different physic behaviors. Even 1 object can have more physics behaviors. To simplify addressing a certain behavior in the events, its handy to Name them.

    3/ Gravity

    __is a switch. Will the object be influenced by gravity or not ?

    4/ Immovable.

    __is a switch. Objects with a physics behavior will only interact using that behavior with other objects if they also have a physics behavior. Simply stated: To bounce the object from a "ground' object. Also the 'ground' object needs to have the physics behavior. But since we do not want the ground to bounce, or move, or even shake 1 pixel, we can set it to 'Immovable' with this switch.

    5/ No rotation.

    __ switch. Allow the physic forces to rotate the object or not.

    6/ Mass

    __ can be tweened in the layout and in the actions. Just stands for how heavy the object is. Heavier objects do not fall faster. But they act different to forces added to the object by user, or by the physics system.

    7/ Linear damping.

    __ can be tweened in the layout and in the actions. Gravity is not a constant speed. When you let something fall. It starts with a zero speed. And how longer it falls, it will build up its speed. Falling faster and faster. Now lets say: When you jump from a high building. You will not accelerate for ever. There is the air that resists, your cloths, and so many other things, causing you to at one point fall with a speed close to constant.

    To represent reality in a physics system we need to have something thats damping the acceleration. You can use Linear damping to archive this. You should give bigger objects a bigger damping then small objects. And feathers even a very big damping.

    8/ Angular damping.

    __ can be tweened in the layout and in the actions. And is to damp the accelerations in the forces that make an object rotate.

    9/ Collision mask.

    __ is a switch. Bounding, Ellipse, or none. None will exclude the object from any collisions / bouncing MADE BY THE BEHAVIOR only. When you trow a square at a wall, the forces that make it bounce back and rotate, are different then when you trow a ball at the same wall. To set this switch right, just ask yourself: Do i want the object to behave as a ball, or as a block. Do not mix this up with the objects collision method. They work together. This mask will alter the way the object is reacting when colliding. The objects collisions method properties define WHERE exactly (at witch pixel related to the sprite) the collision will happen.

    10/ World solver. 11/World friction. 12/World x scale. 13/World Y scale.

    __ oh i dont understand this yet. So plz comment if you know its function.

    14/

    World gravity.

    __ __ can be tweened in the layout and in the actions. Stands for the acceleration of the gravity.

    9,8 means: Each second the gravity will go 9,8 units/second faster .. and damped by the linear damping value.

    Next post i take the behavior to the events editor, and walk step by step trough it there.

  • shoooo !

  • You dont sound as asking for help, more as stating facts. But if you list up problems with Construct i have this urge to put in my 2 cents.

    If you need help with this, then upload a .cap.

    Now i have to assume, and picture myself a way trough how i think your events look like.

    So i assume you made a copy of the characters sprite, erased some outer things as "the tip of the head", and this new sprite you use as sensor, in pixel detection mode. I sure can imagine this construction going stuck. Try to figure out a bounding that does the same, if needed 2 separate simple objects, and use the bounding collision method.

    I have no idea how you drive the sensor, how you snap the character to the sensor, and how you align your animations. Plz trow in a .cap.

    One thing about animations though. I noticed that since the last release, Animations stop playing when you auto-align angles from a angle-sub-animation with more frames to an angle-sub-animation containing only 1 frame. Just go to the Animator, and right click the lonely frames to copy and past. So you have at least 2 frames in each animation. When its a non moving animation, just 2 the same frames, of cours. And all problems with animations not playing are gone.

    And about your last point.

    The "8 directions" behavior can be set on "ignore keys', if thats what you use to drive the sensor.

    Ashley brought "slow-motion" into construct. I have not played with it myself yet. So i have no idea if its possible to slo-mo parts of things. But then again ....

    What you describe should not be a problem. If you bring a nice flow into your events.

    If you let the keys alter variables, and move, fire, sit, stand, according those variables. Then you only need 1 global variable that represents the state your games is in.

    Then if you organize all your events in nice event trees,

    All you have to is open a tree with checking the global " FloW variable".

    Like ...

    key 'fire' pressed

    _______ set the flow to fire

    'flow'' set to fire ?

    _______ is the thing allowed to fire, yes or no

    'flow' not equal to "fire"

    _______do all the moving stuff

    'flow' equal to 'fire"

    _______do all the fire stuff, and when done set 'flow' back to moving

    Its easy to drive a complicated game on only 2 "flow" variables.

    Greetings : ) ( to stay on topic )

  • ,,

  • You can using the tracking hided in the turret behavior.

    Give it a low rotation speed. And it will slowly rotate towards its target.

    Or fast with a hight rotation speed, as you wish.

    Snap its position to your object, and snap the objects angle to the turret angel.

    A small .cap to illustrate.

    download/file.php?id=100

TheInstance's avatar

TheInstance

Member since 5 May, 2008

None one is following TheInstance yet!

Trophy Case

  • 16-Year Club

Progress

16/44
How to earn trophies