How do I change the position where an object is pinned?

Get help using Construct 2

Post » Fri May 05, 2017 8:53 am

I am currently creating a game based on the classic arcade game "Frogger". When the frog (with an 8 direction behaviour) jumps on a log (with a bullet behaviour) I would like it to be pinned to the position of the log. I currently have a pin behaviour on the frog and have the following events.

Condition: Frog is overlapping log Action: Frog pin to log (position only)
Condition: On any key pressed Action: Frog unpin

The frog does pin to the log, however no matter where the frog jumps onto the log, the frog pins right on the edge of the log. Is there any way I can change where the frog will pin to the log? I have tried changing the origins and collision polygons of both the frog and the log but have had no success.
B
4
S
1
Posts: 6
Reputation: 314

Post » Fri May 05, 2017 9:13 am

Well, your condition says "Frog is overlapping log", so yes, from the moment the two objects will be in touch, they'll be pinned.
And so it means from the moment the frog touches the edge of the log.

You should add more conditions to the "Overlapping" event to check out the current Y position of the frog in regards to the log :
Frog is overlaping Log
Frog.Y > Log.Y - 24
Frog.Y < Log.Y + 24

Those two added conditions would check a range and only pin the Frog when it is about 48 pixels from the Log.Y position.
Adjust this value accordingly to the height of your log.

Also you can add a condition Set Frog.Y to Log.Y in order to have the frog in the middle of the log (assuming your origin point is in the middle) before the pin action.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
284
S
109
G
91
Posts: 7,317
Reputation: 87,483

Post » Fri May 05, 2017 9:06 pm

@kyatric Thank you for your help
B
4
S
1
Posts: 6
Reputation: 314


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 6 guests