# How do I make working the vactor X ???

Get help using Construct 2

### » Sun Oct 05, 2014 2:40 pm

Hi guys, somehow my Vector X is not working.....just a few pixels maybe....
in another part the vector Y is doing fine...but here the vector X is not really working...obviously my fault...but why ?
here is my code...it's like in super mario that after hiting the enemy, the player bounces away for a certain distance of pixels...

mess.jpg

sorry...I am beginner,....and I really shame in front of so tough guys like U who can code like Pros...
2 long days...I am tring to see tutorials manuals and asking help...

thanks
You do not have the required permissions to view the files attached to this post.
B
41
S
17
G
2
Posts: 473
Reputation: 5,117

### » Tue Oct 07, 2014 12:56 am

The deceleration setting is likely changing the vector x back to 0 quickly. Which it is made to do. The solution would be to set the deceleration to 0 before setting vector x. Add a wait action then set the deceleration back up to let it move for a bit.

ex.

set deceleration to 0
set vector x to 100
wait 1.0 second
set deceleration to 1000

^That will move the object 100 pixels over 1 second. You could make it only take half a second with:

set deceleration to 0
set vector x to 200
wait 0.5 second
set deceleration to 1000

You can calculate the distance moved, vector x to use and time to use with this equation:
distance = vectorX * time

You just need to have two of the values and you can calculate the other by manipulating the equation.
B
98
S
36
G
132
Posts: 5,525
Reputation: 84,013

### » Tue Oct 07, 2014 8:09 am

very kind thanks...is it possibile to see a small capx sample ?

thanks a lot
B
41
S
17
G
2
Posts: 473
Reputation: 5,117

### » Tue Oct 07, 2014 8:40 am

R0J0hound is best person to ask
B
265
S
49
G
15
Posts: 2,028
Reputation: 42,733

### » Tue Oct 07, 2014 8:51 am

Ah ok I maged it that was super helpful...how can i mange this :
...if the player hits from left the enemy, player bounces back left...if player hits enemy from tight,...it bounces to right side

anyway thanks,,,that was awesome
B
41
S
17
G
2
Posts: 473
Reputation: 5,117