Carry a Object

For questions about using Classic.

Post » Thu Apr 22, 2010 4:52 pm

Hi I'm new to Construct and I have been having a little trouble trying to figure out a way to have my platform character carry an object over his head. I want him to be able to carry a object that he is overlapping when the player presses a button, and then when the button is pressed again he will throw or drop the object.

I tried searching the forums but I haven't found an answer yet.

So whatever you think the best way of handling this is please let me know. Thanks in advance.
B
31
S
6
G
7
Posts: 140
Reputation: 5,983

Post » Thu Apr 22, 2010 10:55 pm

In its simplest form you want to be looking at using a flag variable like "Carrying" to see if you're carrying something, and use a private variable as a flag for instances of your objects you want to carry.

[color=#000080:2r0dw3fl]To pick up an object:[/color:2r0dw3fl]

>Button Pressed
+Carrying is 0 (false)
+Overlapping object
---PrivateVariable=1
---Carrying=1

[color=#000080:2r0dw3fl]To drop an object:[/color:2r0dw3fl]

>Button Pressed
+Carrying is 1 (true)
+PrivateVariable=1
---PrivateVariable=0
---Carrying=0
---[Update object with new position coords]

[color=#000080:2r0dw3fl]And use an Always to position object above player:[/color:2r0dw3fl]

>Always
+Carrying=1
+PrivateVariable=1
---[Position object above player]

You can improve it by making sure that you can't pick up whilst overlapping more than one object, and you can't drop whilst overlapping another object.

Krush.
B
2
S
2
G
3
Posts: 406
Reputation: 2,062

Post » Thu Apr 22, 2010 11:04 pm

Thanks a ton for your help I'll give it a shot.


Edit: This worked out really well, thanks. :D
B
31
S
6
G
7
Posts: 140
Reputation: 5,983


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest