Suggestion for Ball behaviour + a physics bug

This forum is currently in read-only mode.
0 favourites
From the Asset Store
Match same tiles with each other as fast as you can and earn more score during a limited time!
  • I don't suppose it would be possible to add a set X component and set Y component to the Ball behaviour would it?

    Plus while I'm writing, are you aware that the ellipse collision mask for the new physics engine is a perfect circle regardless of the dimensions of the physics object?


  • I was messing with the ellipse as well, and I noticed it doesn't roll unless it's tilting off another object. It's not a big issue for me, but I did think it looked a little odd.

  • Yeah, the new physics engine has a few bugs. We'll try have them sorted for the next build.

    I'll add that to the ball behavior quickly...

  • Actually, for ball behavior, all you need to set the X and Y components are:

    Set angle of motion to angle(0,0,x,y)

    Set speed to distance(0,0,x,y)

    Do you think I should add special actions?

  • I was originally doing something like that but what I found was, since i was using variables for my 'Xforce' and 'Yforce', it messed up the bounces pretty hardcore. The object was trying to push through obstacles rather than bounce off them since the X/Y components were 'set in stone' so to speak and it was hard to alter the variables upon collision to make the ball bounce off at the right angle.

    If you don't think it's appropriate to add them, that's fine, I guess I am using the ball behaviour a little differently than it should be used.

  • I'm using the platform behavior to make balls fall in a specified direction depending on which way gravity pulls them. To disable jumping, you just set the jump strength to zero. I'm sure that's not how the behavior was intended to be used.

  • I'm at college so i can't check, but does the platform movement bounce? I'm really using the ball movement so i don't have to code realistic bounce formulas

  • You combine the behaviors and disable the gravity of the ball behavior. You have to adjust the settings a lot to get it to act the way you want it to, but I'm positive it works, because I did it myself.

    Here's a link to the cap I was using the behaviors in: CLICK HERE!

    It has a few bugs and needs a lot of work, but it works.

  • Sorry to ressurect this slightly older thread, I've been unable to use my internet for a long time. Thanks for the suggestion fantasyjam but i think what i want is slightly different.

    What i want to do is similar to the movement that i made in my super speed example in the 'your creations' forum.

    I want to update the X and Y components of movement every tick to give a controlled 'space' type movement. I can get the movement moving exactly how i want it to move, except i can't for the life of me code in the right collision code.

    See with something like:

    set angle of motion (0, 0, Xvariable, Yvariable)

    set speed to distance (0, 0, Xvariable, Yvariable)

    The movement works prefectly, until you collide with something, the ball/player just tries to keep going through the obstacle rather than bounce off because it's X and Y components of motion are fixed into variables rather than being updated upon a collision, meaning, so is the angle of motion.

    What i would like (semi pseudo code):


    set angle of motion (0, 0, Ball X component, Ball Y component)

    When W(forward) is down:

    set ball X component to ball X component + (cos(player angle) * AccelerationVariable)

    set ball Y component to ball Y component + (sin(player angle) * AccelerationVariable)

    If i could alter the ball movements X and Y components directly, just like i can in platform or physics, i would still be able to get the spacey type motion but bounces would work perfectly fine too because the ball behaviour works out which angle to bounce at and changes the X/Y components accordingly. It would also open up more avenues for advanced ball movement controls, like what you're doing, you could easily make multiple gravity wells.

    I hope i made myself clear enough :S

    Anyway, to summarise my post, I'm begging you Ashley to add set X/Y components to ball behaviour!!!!!!

  • Maybe you're better off writing a custom ball movement? As you mentioned, if you're always overriding the velocity, when it bounces it's still trying to go in the old direction, and you need to update the variables.

    Adding set x/y component won't magically fix this, because the action will just call set angle of motion and set speed for you, with the math. So it'll work exactly like it does with your current method.

  • You sure? Cause if there was a set X/Y component, I wouldn't be using variables and wouldn't have to override the velocity.I would be adding a certain value to the component's current value, not setting it to a fixed amount. Making it, to my understanding, so the ball will still bounce off obstacles.

    So let's say when i press forward it adds 2 to my X component

    Say the ball object is travelling at an X component of 50, i press forward, it takes the current X comp and adds 2 to it, making my ball object travel at 52 pps

    Suppose then the ball collides with something, the ball behaviour, to my understanding then calculates the new angle of motion and adjusts the X and Y components, so let's say that after said collision, our X component is now -52

    I press forward again and it adds 2 to the X component again making it -50

    See where i'm going? This way, the current X/Y component is taken into account when moving the player. Is my thinking wrong? Did I explain myself properly?

    Otherwise i WILL probably have to make my own custom movement.

    The only problem I can see with making my own ball movment is I can't get the bounces and angle of motion after the collision as accurate as the ball behaviour does. As in, the ball behaviour seems to take into account the shape of the sprites, whereas i cannot find the shape of things using events very easily.

    Anyways thanks for reading and all the work you're doin

  • If you want to add 2 to the X component only of the ball movement, then use:

    set angle of motion (0, 0, Xvariable + 2, Yvariable)

    set speed to distance (0, 0, Xvariable + 2, Yvariable)

    As I said, those actions are identical to a 'Set X and Y components to Xvariable and Yvariable' action. You can retrieve the current X and Y components of the ball's movement via its expressions as well.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • But the ball behaviour's X/Y components will change automatically upon collision would they not? whereas if i had to use variables i would have to find a way to calculate the new velocities

  • It works with other behaviors, it should work with ball too.

    But anyways, since it seems like i'm not going to be able to set the ball movements X/Y velocites, how does the ball behavior determine the angle of bounce?

    Because I've got a custom movement set up and I really need ball/physics type bounces but those are dam hard for me to code.

    Wouldn't it be cool to have some sort of generic 'bounce off object' type function, regardless of behaviour, where you put in the player object's X and Y velocites, and that of the obstacle (if it's even moving) and then construct does whatever it does to figure out the bounce direction for the ball and returns the new X and Y components for the player object which you would then have to store somewhere obviously.

    I understand this is a pretty flighty, unrealistic and almost fictional suggestion, but it would be cool to be able to do realistic bounces (as in those that take into consideration the shape of the sprite) to custom movements. I'm not sure how you would go about it since the X and Y velocites would be stored in variables so if that system ever worked you would have to find a way to return two separate values which you can then assign to whatever you want.

    If you're thinking, 'But Arcticus, just use the ball behaviour, it bounces fine', yes it does bounce fine, but not when it's angle of motion is fixed because of using varibles for X and Y velocites instead of editing the ball's X/Y components directly. Setting the angle of motion and speed i can do fine, it's the bounces that it stuffs up.

    Here's a little example of what i mean if you don't get me, it uses the platform movement only to show that proper bouncing whilst using the Set X component and Set Y component is completely possible, please ignore the odd direction of the platform bounce as it is not intended to be used this way:

    Hopefully that conveys what I want

  • Well, that example has made me curious now if the addition is indeed needed.

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