Physic-based problems

Get help using Construct 2

Post » Wed Jan 08, 2014 3:44 pm

Hello!

I am currently designing a game where the player must cascade from the sky to the ground while maneuvering around enemies and collecting coins. The protoype is coming out nicely, but I have stumbled upon some physic-based problems that I can't seem to find a solution for (im not a programmer)

1 - The player has no control of the sprite aside from moving left and right. Adding this was easy using the basic physics behavior. However, when the player moves left and right they do not continue falling. Instead they stop mid-air as long as the key is being pressed.

2 - I want the player to be able to slow down when holding the up key and speed up when holding the down key. Im not really sure how to code this in the event section.

Sorry if these questions seem kinda basic, Im still a newbie :(

Thanks in advance.
B
4
Posts: 7
Reputation: 214

Post » Wed Jan 08, 2014 3:49 pm

@BrandonJaySolus
are you using other movement behaviours alongside physics? They don't get along very well

if you're using physics, it's best to control all of it's movement with those physics actionskeepee2014-01-08 15:50:46
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

Post » Wed Jan 08, 2014 4:04 pm

Yeah, the 8-directional behavior. I just turned it off and added the apply force event instead. Seems to be working now. Thanks!

Problem 1 down! (That was fast lol)
B
4
Posts: 7
Reputation: 214

Post » Wed Jan 08, 2014 4:12 pm

@BrandonJaySolus

if you want stronger control over the object, you should try using 'Set Velocity'

if you want to set the X component, but leave Y alone, you can do:

set X component to [whatever speed you want]
set Y component to self.physics.velocityY
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

Post » Wed Jan 08, 2014 5:15 pm

Thanks for the tip. Is there a way to maintain that force and velocity using a variable? So that whenever the player is holding the up/down key their speed remains constant instead of gradually moving towards said angle (which is my main prob atm). I would upload the capx but it seems I cant do that yet (made this account today).
B
4
Posts: 7
Reputation: 214

Post » Wed Jan 08, 2014 5:27 pm

If you use key is down - set speed, it should set the speed every tick amd thus the speed would stay the same..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Jan 08, 2014 5:41 pm

That doesn't seem to work (the only Set Speed I see Is in the animation category). My code looks like this

Conditions
Keyboard : Up arrow is down
System: Every tick

Actions:
Sprite: Set animation speed to 5
            Apply physics force() at angle () at image point 0
            Set physics velocity to (self.physics.velocityX, 2)

This for the controlling speed when holding up/down.
B
4
Posts: 7
Reputation: 214

Post » Wed Jan 08, 2014 5:46 pm

Ok, so instead of apply force, set the velocity every tick, like @keepee said.

If you use key is down - set VELOCITY, it should set the VELOCITY every tick and thus the speed would stay the same..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Jan 08, 2014 6:00 pm

Ah, i thought I was supposed to have both force and velocity on. Everything seems to work now. Thanks keepee and LittleStain!
B
4
Posts: 7
Reputation: 214


Return to How do I....?

Who is online

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