How do I modifie CustomMovement speed and rotation

Get help using Construct 2

Post » Thu Feb 05, 2015 9:14 pm

Hi, I want to set a maximum speed to my player (a submarine) but I can't figure out how. I modified the "CustomMovement: Set speed" but it doesn't go right. Is there an easy way to do this?

Also, when I release the accelerate button, there is a distance interval where the player is decelerating and then stops. If I rotate the player (to the left or right) in this distance interval he will not change his liniar trajectory. Is it possible to influence that just a bit with the left and right buttons?

Thanks in advance
You do not have the required permissions to view the files attached to this post.
B
27
S
8
G
4
Posts: 168
Reputation: 3,886

Post » Thu Feb 05, 2015 9:27 pm

Could this solve your problem?
I added maxSpeed variable and additional condition on 1. event
You do not have the required permissions to view the files attached to this post.
B
12
S
6
G
2
Posts: 99
Reputation: 1,727

Post » Fri Feb 06, 2015 5:39 pm

Hi razorMonkey, I just tried what you said. The player have a maximum speed now but it doesn't change his trajectory when I press left and right buttons. Can you drop the .capx here? ... maybe I've done something wrong, I'm not good at reproducing :).
B
27
S
8
G
4
Posts: 168
Reputation: 3,886

Post » Fri Feb 06, 2015 7:01 pm

Sorry, I just took care of maximum speed. Now I will take care of the angle of motion.

anty21ro wrote:Can you drop the .capx here? ...

No. That would be too easy :)


As you can see on the picture, I added two new actions in line 5 and 6 that will take care of the angle of motion.
Now if you wish that angle of motion follows smoothly angle of submarine rotation it should be the same as rotation of submarine (like in this example, 125). If you want some inertia you should lower it and it will feel like drifting with car. If you make it higher it will act strangely. Try to play with it to get the result you like.


EDIT:
also I would suggest that you add dt to acceleration and deceleration, otherwise it will act differently with different framerate

EDIT 2:
just ignore line 2, I put animation speed by mistake :oops:
You do not have the required permissions to view the files attached to this post.
B
12
S
6
G
2
Posts: 99
Reputation: 1,727

Post » Sat Feb 07, 2015 10:03 am

Hi again, I modified like in the image above and it works to a point where ... if I accelerate and rotate to a certain degree the player continue to go in that direction but facing the wrong way ... I don't know if I explained corectly , sorry for my bad english.

If I add dt to acceleration (250 * dt) and deceleration (-250 * dt), it's not moving at all. I did something wrong I think.
B
27
S
8
G
4
Posts: 168
Reputation: 3,886

Post » Sat Feb 07, 2015 11:34 am

I see where could be the problem. If your speed is greater than max speed he will not add enough additional speed to your direction. So I tried with different approach, it seems to work now.
So instead of subevent in line 2 I added new event in line 3.

As for adding dt in acceleration and deceleration, my mistake, it seems Custom Movement behavior already incorporates DT in acceleration so ignore my advice here :)
(but you will need it for any movement you will be coding on your own)
You do not have the required permissions to view the files attached to this post.
B
12
S
6
G
2
Posts: 99
Reputation: 1,727

Post » Sat Feb 07, 2015 12:37 pm

Thanks man, you helped me alot.
B
27
S
8
G
4
Posts: 168
Reputation: 3,886

Post » Sat Feb 07, 2015 3:15 pm

But does it work now? Or do you thank me just to be polite? :)
B
12
S
6
G
2
Posts: 99
Reputation: 1,727

Post » Sat Feb 07, 2015 10:20 pm

Yes, it works, I assume you test it to :)
B
27
S
8
G
4
Posts: 168
Reputation: 3,886


Return to How do I....?

Who is online

Users browsing this forum: anty21ro and 3 guests