Activate event on physics moving up or down?

Get help using Construct 2

Post » Sun Feb 26, 2012 1:37 pm

Hi

As the titel implies i am searching for a way to be able to connect an event to the direction movement of the physics, as in (moving up on the Y axis, or moving down on the Y axis.)

Its for a ball in a sort of pinball game by which i need a set of options relative to when the ball is moving up the leven or down the level.

I thought of pure angle events but as far as i understand at this point the angle only gives a (is facing towards) gesture.
Not an (is moving down on Y or up on Y)

In short the event i am trying to create is:
If Sprite (Ball) moves Up on Y & mouse click button 1 then: action 1
If Sprite (Ball) moves Down on Y & mouse click button 1 then: action 2

Any idear would be very kind.
Thanx!


Savvy001Savvy0012012-02-26 13:37:57
B
56
S
20
G
13
Posts: 778
Reputation: 13,204

Post » Sun Feb 26, 2012 3:37 pm

Ball.Physics.VelocityX > 0 move right
Ball.Physics.VelocityX < 0 move left
Ball.Physics.VelocityY > 0 move down
Ball.Physics.VelocityY < 0 move up
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sun Feb 26, 2012 5:26 pm

Yann!
Thank u.

This opens up so much gameplay
B
56
S
20
G
13
Posts: 778
Reputation: 13,204

Post » Thu Mar 08, 2012 9:38 pm

I'm doing something similar, and wondered if there is a way to capture the actual angle of the ball?

I was hoping to avoid arc cosines and dot products if possible. :)

Is there an expression to get this variable?JohnnySix2012-03-08 21:39:03
Image
B
27
S
9
G
5
Posts: 487
Reputation: 11,939

Post » Thu Mar 08, 2012 10:08 pm

@JohnnySix

When looking for something realated to physics in an event just type (spritename).physics.(then a dropdown list apears)

Just as Yann taught us here: Ball.Physics.VelocityY gives us the Y velocity of the physics of the ball.

What i did was use the (Compare two values) option.

I used it as in:
If: Ball.Physics.VelocityY greater than 300
Then: Activate action

The .Physics expression also has angle measurement.
So my gues is that u could do a similar thing.
Savvy0012012-03-08 22:11:17
B
56
S
20
G
13
Posts: 778
Reputation: 13,204

Post » Thu Mar 08, 2012 10:44 pm

angle(0,0,Ball.Physics.VelocityX,Ball.Physics.VelocityY)
gives you the angle of the movement
dunno if there's an expression for that now
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Thu Mar 08, 2012 11:22 pm

Thanx!
B
56
S
20
G
13
Posts: 778
Reputation: 13,204

Post » Fri Mar 09, 2012 7:50 pm

@ Savvy001 - I was just using vectors to keep it simple - am placing a target in the path the object is travelling for bug testing and potential collision issues. :)

@ Yann - Thanks - just what I was looking for - there is no expression as yet, and it's a useful variable to have.

@ Savvy001 again - looking forward to your pinball game. :)
Image
B
27
S
9
G
5
Posts: 487
Reputation: 11,939

Post » Fri Mar 09, 2012 7:59 pm

@JohnnySix

Thanx!
Its going to be in the google chrome store when ready.
And probable in the windows store later on in the future.
So im looking forward to the end result.
The team working on the game has just grown bigger.
Today a music producer has joined us.
And the game already has become quite addicting to testers.
B
56
S
20
G
13
Posts: 778
Reputation: 13,204


Return to How do I....?

Who is online

Users browsing this forum: Nifl and 29 guests