Applying strings to Set position, Set X or Set Y?

Get help using Construct 2

Post » Mon Mar 25, 2013 7:12 pm

Hi. I am currently having a hard time setting an object's position based upon the value of a variable. This value contains the information of how much the player has moved a certain direction since last tick.

The object is a bullet constantly flying towards the player, however I want the bullet to move away from the player when the player runs towards the bullett in the exact same speed as the player is moving. All I need in order to be able to pull this off, is to apply a variable to a "set X", "Set Y" or "Set Position" event, but construct won't let me apply strings to these types of events. Any ideas?

Here's an image illustrating the problem: http://puu.sh/2nQmJ

Thanks!
B
22
S
7
Posts: 316
Reputation: 2,490

Post » Mon Mar 25, 2013 7:27 pm

Typically you can wrap something in int() but you are trying to set a string inside it (ComboBoxRight.X="") which makes no sense.

Wouldnt you want ComboBoxRight.X - PlayerXCoordLastTick ?Equinox802013-03-25 19:28:09
B
26
S
5
G
5
Posts: 98
Reputation: 4,734

Post » Mon Mar 25, 2013 7:39 pm

When I wrote it like that the bullet completely disappeared. I guess the bullet was affected in one way or another, but definately not as intended. When standing still the value of PlayerXCoordLastTick will be 0, thus not affecting the path of the combobox, but it disappeared.

Any other way to make the event read the value of the variable?Tinimations2013-03-25 19:39:30
B
22
S
7
Posts: 316
Reputation: 2,490

Post » Mon Mar 25, 2013 7:45 pm

Could you share the capx?

Otherwise,

Variables are read by ObjectName.VariableName So I'm not quite sure what you mean.
B
26
S
5
G
5
Posts: 98
Reputation: 4,734

Post » Mon Mar 25, 2013 7:57 pm

Here's the capx: http://www.2shared.com/file/h9xkrMZJ/Test_project.html

The event in question is event 5 on the "Core mechanics sheet"

Thank you.
B
22
S
7
Posts: 316
Reputation: 2,490

Post » Mon Mar 25, 2013 8:09 pm

Alright I don't know exactly what you mean, I disabled that event and the bullet moves left, toward the player.

Do you want it to move away when the player presses right, at the right spot?
B
26
S
5
G
5
Posts: 98
Reputation: 4,734

Post » Mon Mar 25, 2013 8:10 pm

Hmm seems like you explained it right to begin with, it's just a flaw in with the PlayerXCoordLastTick.

Thank you regardless

Edit: No I want the bullet to always fly towards the player, but I also want the bullet to move with the character when the player is running either right or left. So in other words I want the bullet to take the exact same amount of time to reach the player regardless of how fast the character is moving. Did that make any sense?Tinimations2013-03-25 20:11:49
B
22
S
7
Posts: 316
Reputation: 2,490

Post » Mon Mar 25, 2013 8:10 pm

Alright, no problem!

Edit: Yes it does very much, you could always set the speed to 200 + the Player's speed, if moving.Equinox802013-03-25 20:13:57
B
26
S
5
G
5
Posts: 98
Reputation: 4,734

Post » Mon Mar 25, 2013 8:17 pm

It won't be precise enough, but I've solved the problem now. The source of the issue was that I placed the event right below the event that resets PlayerXCoordLastTick to the current position of the character. This sent the combobox into the abyss and kept it there.

Thank you again though for the help!
B
22
S
7
Posts: 316
Reputation: 2,490

Post » Mon Mar 25, 2013 8:18 pm

Ah alright, you're welcome.
B
26
S
5
G
5
Posts: 98
Reputation: 4,734

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 21 guests