Throwing physics objects

Get help using Construct 2

Post » Thu Nov 17, 2011 12:37 pm

Hi, I'm very new to Construct and coming from a long history with Flash development it's somewhat of a revelation. I'm still waiting to see the limitations, but so far I've been really impressed.

I have one problem though and that seems to be that I can't get any of the physics forces working. I'm trying to create a little physics demo that allows you to pick up objects and throw them. I have the physics world set up and the drag and drop element is working, but for the life of me I can't apply any physics force to simulate the throw on mouse release. My current project can be found here: http://www.codeandvisual.com/test/construct_physics/physics.capx

I've set up last_x and last_y variables on the sprite objects so I can monitor the movement between frames, however I've put that to the side for the time being and am just trying to apply a hard coded force of(1000,-1000) - which to my mind would make it go up and to the right when you release the mouse after dragging a sprite. I've similarly tried setting impulses and setting the velocity directly, but nothing seems to produce any sort of movement besides falling straight down due to gravity.

What am I doing wrong? Eagerly hoping someone can set me on the right path!

jumprock2011-11-17 12:39:37
B
16
S
5
G
1
Posts: 43
Reputation: 1,595

Post » Thu Nov 17, 2011 1:35 pm

Well I don't know why sometimes physics behave strangely and seems to be not working, I hope someone can explain us this better.

Although in your case what you can do that seems to be working fine is set the physics action to be the last one in the event that triggers it and set a wait action before it of about 0,1s. (I changed the apply force to apply impulse and it's working fine)Tuiii2011-11-17 13:36:10
B
19
S
3
G
3
Posts: 56
Reputation: 2,496

Post » Thu Nov 17, 2011 6:09 pm

You could use the following events to throw an object:



Here's a capx download
B
19
S
6
G
7
Posts: 1,206
Reputation: 7,300

Post » Thu Nov 17, 2011 8:37 pm

I'm also interested in a solution for this. How to make the dragging so it appears that the object is bound to the mouse by a rubber band ? That's how it works by the way in all physics examples i've seen. If you simply apply a force towards mouse it doesn't works since the object flies towards the mouse point than passes it than flies towards it again than passes it and so on. I'm sure there's an easier way to do this. The above example unfortunately doesn't work as expected.Kiyoshi2011-11-17 20:43:21
B
58
S
13
G
10
Posts: 632
Reputation: 12,505

Post » Thu Nov 17, 2011 9:23 pm

You could try this:



capx

Hope this helps
B
19
S
6
G
7
Posts: 1,206
Reputation: 7,300

Post » Thu Nov 17, 2011 9:51 pm

Thanks chrisbrobs - by adding in the wait command after mouse release everything started working. Slightly uneasy that you have to do that but obviously there's an explaination based in the physics engine somewhere. This works now, file can be downloaded here by anyone interested.jumprock2011-11-17 21:52:58
B
16
S
5
G
1
Posts: 43
Reputation: 1,595

Post » Thu Nov 17, 2011 10:22 pm

@chrisbrobs It gives me an unknown plugin id . Did you use a custom plugin ?
B
58
S
13
G
10
Posts: 632
Reputation: 12,505

Post » Thu Nov 17, 2011 11:51 pm

[QUOTE=Kiyoshi] @chrisbrobs It gives me an unknown plugin id . Did you use a custom plugin ?[/QUOTE]

Might be the 'touchmouse' plugin by Rexrainbow?
B
19
S
6
G
7
Posts: 1,206
Reputation: 7,300

Post » Fri Nov 18, 2011 12:05 am

Kiyoshi wrote:

chrisbrobs It gives me an unknown plugin id . Did you use a custom plugin ?

Example using the standard mouse:


capx
B
19
S
6
G
7
Posts: 1,206
Reputation: 7,300

Post » Fri Nov 18, 2011 2:50 am

On a side note, since they were mentioned here, what are plug ins written in and how do you go about making one?
B
16
S
5
G
1
Posts: 43
Reputation: 1,595

Next

Return to How do I....?

Who is online

Users browsing this forum: Scofano and 27 guests