Stuck with a few questions

Just started using Construct 2? Post your questions here

Post » Fri Mar 18, 2016 12:28 pm

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.
B
19
S
7
Posts: 161
Reputation: 1,751

Post » Sat Mar 19, 2016 2:09 am

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,
B
33
S
14
G
4
Posts: 172
Reputation: 4,033

Post » Sat Mar 19, 2016 2:12 am

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.
B
33
S
14
G
4
Posts: 172
Reputation: 4,033

Post » Sat Mar 19, 2016 4:43 am

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.
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
51
S
24
G
30
Posts: 521
Reputation: 19,592

Post » Sat Mar 19, 2016 8:24 am

@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.

@LaDestitue - 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.
B
19
S
7
Posts: 161
Reputation: 1,751

Post » Sat Mar 19, 2016 8:50 am

For understanding what exactly raycasting is and it's general purposes, check out this good video:
https://www.youtube.com/watch?v=aTbw71EpamY
(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.
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
51
S
24
G
30
Posts: 521
Reputation: 19,592

Post » Sat Mar 19, 2016 8:57 am

Nice example of raycasting by R0J0hound HERE if anyone's interested.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
84
Posts: 5,375
Reputation: 58,432

Post » Sat Mar 19, 2016 11:12 am

Thanks a lot guys for your reply. I am checking the example you linked @zenox98. 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 :)
B
19
S
7
Posts: 161
Reputation: 1,751

Post » Sat Mar 19, 2016 12:36 pm

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...
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
51
S
24
G
30
Posts: 521
Reputation: 19,592

Post » Sun Mar 20, 2016 4:33 am

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)
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
51
S
24
G
30
Posts: 521
Reputation: 19,592

Next

Return to Beginner's Questions

Who is online

Users browsing this forum: brunopalermo and 0 guests