Stuck with a few questions

0 favourites
  • 11 posts
From the Asset Store
Stick Survivor drawing for Zombie Attack Series with nice style and colors.
  • Hi,

    I am trying to make a game with elements of break out and I am stuck with a few behaviors I am unsure how to solve:

    1- In my game sometimes the ball reaches high speeds over time, when that happens the ball sometimes ignores collisions, how can I make sure the ball doesn't do that? Note the high speeds don't exceed 2300 for example.

    2- How can I change the direction of the bounce depending on the collision location between the paddle and the ball? I tried doing Set Angle of Motion to "Ball.X - Paddle.X / Paddle.Width" and it didn't quite work at all. Any idea how to make it that the left third of the paddle sends the ball slightly to the left, the right third of the paddle sends the ball slightly to the right and the middle third of the paddle deflects the ball 90 degrees?

    What I opted to do is just add a slope to the collision from both left and right directions but somehow it feels as if it is a hack.

    3- One last question but may seem random (but it isn't), I am trying to use a bullet behavior on an object that acts as a projectile. When that projectile gets a target (let's say a prick), I set its angle of motion to (projectile.x, projectile.y, target.x, target.y) and have the Bullet Behavior property speed set to 400 (no change of angle as angle of motion). But the projectile doesn't rotate to face its target. I tried to use Rotate towards Position and it isn't working, any other solution for this?

    Any help would be appreciated and thanks in advance.

  • For the first question, it might be because its going at a speed where fps is slower than the speed of the ball, so when it catches up the ball already passed the collision point,

  • On the last one, i was having the same issue on my project, and what helped was to change the event to /when on screen // set angle towards: Target.x, target.y Again it helped for my purposes, might help on yours.

  • For the first one, are you using bounding boxes to cover collision detection? The issue there is that bounding boxes (or known as AABB) only covers detection on the frame of collision, and not a frame before or after, unlike raycasting.

    You could utilize rough makeshift raycasting (set a line to the ball, and do collision based if the line is overlapping with other objects) which I have an example for you to figure out from. Raycasting has the advantage of being very precise (find the distance between an object and the edge of another) and thus say, know exactly how far the character is from the ground in pixels, such as when they fall or jump.

    For two, try maybe?:

    angle(Paddle.X, Paddle.Y, Ball.X, Ball.Y)

    I'm guessing the ball isn't directly player controlled, so you may have to use "move at angle" instead with the same line I provided.

    Not sure on three, I'll read over it again soon and try to think of something.

  • arcab072081 - Yes, I am guessing the collision is detected after the ball moves out of the collision area.

    For the solution of the third problem; that was my initial setup but it didn't work at all. I tried Set Angle towards Position, Set Angle Towards Target, Set Angle, Set Angle of Motion, Set Angle of Motion + Bullet Behavior property "Set Angle". I tried the Rotate towards, Rotate object, etc... nothing worked. :/ Not sure if I am trying something complex, but nothing works so far.

    Thanks for the suggestion though.

    - No, I am not using Bounding Boxes, I actually set the collision to a "Circle" of sorts. The raycasting method you are mentioning, I don't quite fully understand, sorry. You also said you have an example, may I know where can I find said example? I might be able to understand with it, yes.

    For the second solution; yes, the ball is a breakout kind of ball, no direct control. So I would have an event that looks like the below:

    Move At Angle:

    Angle =angle(Paddle.X, Paddle.y, Ball.X, Ball.Y)

    Distance = 1 (this is custom depending on what speed I want?).

    I tried that it worked beautifully, thanks a lot.

    Thanks a lot for trying to help on the third, it has been busting my brain over the past 2-3 days. I tried every combination of angles I could find and setting every angle action in the sheet and trying it out with different things and nothing worked. I am guessing it should be simple but I am not sure why it isn't working.

  • For understanding what exactly raycasting is and it's general purposes, check out this good video:

    Subscribe to Construct videos now

    (skip to 2:08 for raycasting)

    Anyhow, while Construct 2 doesn't have raycasting built into as a native behavior, it's general functions can be simulated with some clever eventing. I have a somewhat similar set of events in my project to utilize raycasting, mostly for line of sight and detecting collision for when the player of my project swings their sword (for dealing with enemies). I'll dig through the code of that in my project and try to adapt it to a generic example for an object that moves on it's own for you, so you can hopefully get a good idea of what to do with it.

  • Nice example of raycasting by R0J0hound HERE if anyone's interested.

  • Thanks a lot guys for your reply. I am checking the example you linked Doesn't seem the easiest but I'll see if I can get around to replicating that.

    LaDestitute that video did the trick, thanks a lot. And thanks again for your help

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'll try to get on my example soonish but I've been having a terribad night, sleep wise. So much for Construct 2 and debugging complex systems...

  • I whipped an example for you to use some rudimentary and simple raycasting to do more accurate bouncing:

    https://dl.dropboxusercontent.com/u/589 ... ncing.capx

    (commenting inside too, did that just for you)

  • ,

    Thanks a lot for your help and assistance. This helps a lot! ^_^ Hope your game is going well

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