[SOLVED] Create Actor with given coordinates doesn't work as intended

dtishin

  • Posts: 15
Hi,
I'm trying to create "hits" ("hit" actors) in front of my avatar (emulating a melee strike) when I press Enter.
Running into two problems here:
1. Hits are created to the right of the avatar and above it, but they are not created on the left or below.
2. Hits are created next to the avatar only if the avatar stays within a small area of the scene. If the avatar moves outside this area, the "hit" actors are created not next to the avatar but inside that small area of the scene.
3. Additionally (unrelated to the "create actor" problem above: the avatar gets stuck within a small rectangular area of the scene if it goes to the bottom of the scene.
Screen recording here (60 seconds):
https://www.dropbox.com/s/5g0485nhu7wwhny/Create%20Actor%20-%20testing%20scene.mp4?dl=0
Thanks a lot!

« Last Edit: October 10, 2018, 01:55:56 pm by dtishin »

NerdinaNutshell

  • *
  • Posts: 133
For the attack problem try doing x of self instead of x (on screen) of self (I can't guarantee that'll fix your issue but it's worth of a shot)
Plot Twist... I'm a ghost

dtishin

  • Posts: 15
Hi! It does fix the 2nd issue, but not the main one (no. 1) - the "hits" are created only on the right and above the actor, not below or left.

dtishin

  • Posts: 15
Any ideas, anyone? I tried using custom boolean attributes (e.g. "facing left" = true) instead of the standard "direction of" / "point [actor] towards..." attribute but still the "Hit" actor is created only at 0 degrees and 270 degrees (i.e. on the right or above my avatar), but if it points to 90 or 180 degrees no "Hit" actor is created, even though the logic and syntax seem identical for all directions. What am I missing here?

ariakbari

  • *
  • Posts: 43
I would try saving attributes for all of your player movements. Game attributes. Like

"If (up is down)
 set (UpMovement?) to true"

"If (right is down)
set (RightMovement?) to true"

do one for each, left, right, up, down.

Then instead of direction, try calling on those attributes to place the hits accordingly.

"If (UpMovement?)" or "If (LeftMovement?) etc. instead of "if direction of self=..."

Then so on and so forth use your code to place the hits as you've done. Make sure you are turning off each boolean appropriately as well. This may not fix the issue but this is what I would try as I've never used those direction blocks unless it's an image instance, I'm not sure how great those are. Not too sure about last issue. Set player to always active if he's not

dtishin

  • Posts: 15
Thanks ariakbari, using game attributes actually worked!
And I created just one game attribute ("number" type, i.e. 0, 90, 180, 270 etc.) instead of 4 boolean attributes.
I think it's a lighter solution, and also in this case you can point your character diagonally when two controls are pressed at the same time. And there's no need to have extra lines of code that reset the booleans.
Still wondering why the standard "pointing" function didn't work properly...

ariakbari

  • *
  • Posts: 43
Nice. Number attribute is definitely the way to go, didn't even think about that. Glad I could help.