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

0 favourites
  • 10 posts
From the Asset Store
This collection of music is the beautiful performance of rather small strings ensemble (8 first violins, 6 second violin
  • 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:


  • 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 ?

  • 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?

  • Could you share the capx?


    Variables are read by ObjectName.VariableName So I'm not quite sure what you mean.

  • Here's the capx:

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

    Thank you.

  • 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?

  • 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?

  • Alright, no problem!

    Edit: Yes it does very much, you could always set the speed to 200 + the Player's speed, if moving.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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!

  • Ah alright, you're welcome.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)