How do I make player pick objects.

Get help using Construct 2

Post » Wed Mar 19, 2014 10:24 pm

Hello guys, I discovered Construct 2 and started playing with it, after some time I decided I wanted to make player's character picks up items and drop them actively.

Let me start by saying how thankful I am for some of you brilliant people lookin into this and actually trying to help and contributing, I am not a game developer I just to this for fun as an hobby, so I'm sorry if I tried to do it the wrong way or missed some relevant details, fell free to tell me! (.capx below)

So I got on it and tried lot's of ways to do it (including pin) without success, at first character would pick up the item but if character moves the item would stay on the same place. After a few more tries I made it pick up the item and it would accompany player. This is just to give you some information about what problems I ran into and here's some more details:

My objective:

    Make a character, controled by player which picks up objects and holds them when pressing a key;
    Pressing this key again would make player drop the object in question;
    Also it's important the picked up object follows a imagepoint, for example is player picks up a pistol, this pistol has to follow his hand.
    I was planning to use this to make player change equipments and each part (head,torso,legs) easly with no problems, this would allow characters to use different equipment combinations since everything is attached to a different position.

How I though I would do it:

    Having to sprites, player and item;
    If they were overlapping and "E" key was pressed two things would happen. One it would set a variable to 1, and two it would disable item's physics; If this variable is set to one it would set item's position to the same as imagepoint 1 which belongs to player;
    If key "Q" is pressed this variable is set to 0.
Thanks a lot in advance!

Download .capx file here.
You do not have the required permissions to view the files attached to this post.
B
4
Posts: 11
Reputation: 222

Post » Wed Mar 19, 2014 10:53 pm

Not really sure what the problem is?

Tested your capx and it seems to work just fine, the only thing I could find, which is not really relevant to your problem, is that you have to make sure that imagepoint 1 is copied to the other frames.

You can do that by simply right click it in the image editor and choose copy to whole animation or something like that.

But maybe I misunderstood what you meant regarding your problem.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Wed Mar 19, 2014 11:05 pm

nimos100 wrote:Not really sure what the problem is?

Tested your capx and it seems to work just fine, the only thing I could find, which is not really relevant to your problem, is that you have to make sure that imagepoint 1 is copied to the other frames.

You can do that by simply right click it in the image editor and choose copy to whole animation or something like that.

But maybe I misunderstood what you meant regarding your problem.


Wow, thanks a lot for such a quick reply, my problem now it's the object when it's picked "shakes" a lot and does not stays precisely at imagepoint one.

The cause of the problem could be in the animation because I would not have the same point in all frames and as the point would change so would the position of the item, but look's like it's shaking anyway. I wonder what that could be.

Thanks a lot nimos, if you have any other sugestions for what might solve the problem, please feel free to share them. :)
B
4
Posts: 11
Reputation: 222

Post » Wed Mar 19, 2014 11:28 pm

Ok I understand you now, the shaking of the object is due to you having to copy the imagepoint_1 to the other frames the way I told you in the first post. As I looked at it, some of the frames doesn't have imagepoint_1 and for some of them its not at the same position.

The reason is that as your character goes through each frame, it will stay at imagepoint_1 as you told it, but if its not the same for all the frames, it will shake as it moves to the position of the imagepoint for that frame.

So what you do to be more specific is you place the imagepoint where you want it on frame 0, when you are happy with that, you right click it in the list of imagepoints and tell it to copy it to the rest of the animation, its called "Apply to whole animation" then it will copy the imagepoint to all the other frames.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Wed Mar 19, 2014 11:37 pm

nimos100 wrote:Ok I understand you now, the shaking of the object is due to you having to copy the imagepoint_1 to the other frames the way I told you in the first post. As I looked at it, some of the frames doesn't have imagepoint_1 and for some of them its not at the same position.

The reason is that as your character goes through each frame, it will stay at imagepoint_1 as you told it, but if its not the same for all the frames, it will shake as it moves to the position of the imagepoint for that frame.

So what you do to be more specific is you place the imagepoint where you want it on frame 0, when you are happy with that, you right click it in the list of imagepoints and tell it to copy it to the rest of the animation, its called "Apply to whole animation" then it will copy the imagepoint to all the other frames.


Ok, so following your advice I place every imagepoint to all frames and it did not work, so I deleted all the frames to make sure it would not shake the object, turns out it did. This is so wierd, I don't really see what might be causing this. o_o Did it worked for you? Because I might have done it wrong.

And you are saying it's not the item it's shaking but the character it self? Thanks a lot.
B
4
Posts: 11
Reputation: 222

Post » Thu Mar 20, 2014 12:25 am

I see what you mean, its a bit weird.

I tested it and it seems that it might be a bug with the platform behavior, I haven't used it a lot, so maybe im wrong.

But if you run the game in debug mode and pickup the green ball then select the player and change Max falling speed to 0 then it stops jumping around.

To me that doesn't seem to work correctly, the green ball being linked to the players imagepoint shouldn't get influenced by the players max falling speed. Also as you change the Max falling speed the green ball actually moves upwards, which again seems wrong to me, in a way that the imagepoint of the player, moves according to the max falling speed.

But as I said I have never really used that behavior so maybe im missing something, that someone that have used it knows. But personally I would make a bug report on it and maybe Ashley can verify if its working as intended or not. But to me it seems like a bug. :)
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Thu Mar 20, 2014 1:10 am

nimos100 wrote:I see what you mean, its a bit weird.

I tested it and it seems that it might be a bug with the platform behavior, I haven't used it a lot, so maybe im wrong.

But if you run the game in debug mode and pickup the green ball then select the player and change Max falling speed to 0 then it stops jumping around.

To me that doesn't seem to work correctly, the green ball being linked to the players imagepoint shouldn't get influenced by the players max falling speed. Also as you change the Max falling speed the green ball actually moves upwards, which again seems wrong to me, in a way that the imagepoint of the player, moves according to the max falling speed.

But as I said I have never really used that behavior so maybe im missing something, that someone that have used it knows. But personally I would make a bug report on it and maybe Ashley can verify if its working as intended or not. But to me it seems like a bug. :)


Alright I see, I will look into it and try to make a report, I have to say I'm not really familiar with Construct 2 so I might have made lot's of mistakes. As controling the character, do you think I should use custom controls rather than platform?

And let me thank you again for your help, thanks a lot and a learned a few more things about C2 on the way.

Thanks be well.
B
4
Posts: 11
Reputation: 222

Post » Thu Mar 20, 2014 2:41 am

Alright I see, I will look into it and try to make a report, I have to say I'm not really familiar with Construct 2 so I might have made lot's of mistakes. As controling the character, do you think I should use custom controls rather than platform?


I don't think you made any mistakes regarding the code at least, there are to little code for it to not be noticed.

Well whether you should use one or the other is up to you, they are different behaviors and suit different purposes so it pretty much comes down to the game you are making.

And let me thank you again for your help, thanks a lot and a learned a few more things about C2 on the way.

Sure no problem :)
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Thu Mar 20, 2014 7:16 am

Here you go.
The Fix!

couple of issues with the project nothing major but some of your image-points was not positioned
Also you don't need a global variable to pick up an object it would be best to use a Boolean instance variable on the object you want to pick up.

I hope I helped!
B
19
S
4
Posts: 96
Reputation: 1,487

Post » Thu Mar 20, 2014 11:15 am

Message: MxSmack is not yet permitted to post plain text URLS (300 rep required). 1 URLS removed. Why?
LoganJFord wrote:Here you go.couple of issues with the project nothing major but some of your image-points was not positioned
Also you don't need a global variable to pick up an object it would be best to use a Boolean instance variable on the object you want to pick up.

I hope I helped!


Just tried your .capx, it works with no problems, and it means it can get objects in the air which is awesome. And know that I know about boolean variables I will get some more information about it.

Thanks a lot!
B
4
Posts: 11
Reputation: 222


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 6 guests