How do I stop my unit from getting stuck and rotating ever?

0 favourites
  • 9 posts
From the Asset Store
SCI-FI Units SFX contains 456 sounds With this pack, you can voice almost all the units in your sci-fi strategy game
  • Hi,

    I am new to Construct 3 and having a little problem. I am trying to create a simple RTS game. I want my knight to move close to the goblin, kill it, then move to the next one. Somehow it gets stuck after a while. I used turret + moveto as behaviors. Also, I don't want him rotating. I would really appreciate some help.

    Thank you.

  • The turret behavior is rotating your sprite toward its target. You simply need to uncheck the "Rotate" box in the properties panel.

  • Turret behavior is rotating the knight.

    Also, with multiple goblins you need to pick a goblin instance first. For example, the nearest goblin instance, or the instance with the lowest HP. Once the correct goblin instance is picked, use "acquire target" action in the Turret behavior to start firing at it..

    Alternatively, allow the Turret to automatically pick its target. And then move the knight to that target. Use Knight.Turret.TargetUID to identify the target goblin by its UID.

  • Hi again,

    Thanks for replies.

    Mojobojo, I needed my units to attack other units, so I couldn't uncheck rotation for turret behavior. Instead, I created another sprite, added turret behavior, and pinned them together. 

    dop2000,  I think I solved the problem. Still, move-to behavior doesn't seem to work properly. Sometimes knights don't choose the nearest target. I don't know why. 

    Also using family helped a lot. I will be adding different type of units to armies.

  • Is KnightTurret in the same container with the Knight? If not, then the code that pins them will not work correctly.

    "Acquire target" means a single target - a particular goblin instance among all other goblins. So you need to pick that instance before acquiring! Like I said, it's up to you how to pick it (by visibility, distance, lowest HP etc.), but you need conditions to pick the goblin instance. Please read some tutorials about picking in Construct, it's very important to understand how it works.

    Another option is automatic targeting - use "Add object to target" action. Then turrets will automatically select the target in range. This target can be identified by UID. If you want the knight to move to it, pick the instance by UID first:

    Every 0.5 seconds
    For Each Knight
    Goblin pick by unique ID = KnightTurret.Turret.TargetUID
     -> Knight Move To Goblin
    
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • dop2000, thank you, man.

    I am trying to understand how Construct 3 works. I have been checking tutorials, but there is not much on AI behavior. Even though what I am trying to do is relatively simple. 

    Thanks for the tips on targeting priorities. Right now I am trying to achieve:

    When Elven Archers start shooting, I want them to stop moving, wait for 1 second, then move again. I tried timer behavior with the event sheet but failed. 

    If you have any suggestions on which tutorial to read, I would really appreciate it.

    Thank you.

    i.giphy.com/media/v1.Y2lkPTc5MGI3NjExMDJ0NTRibngxeWh2MXAzNzQ3ZW1mbzNob2JzOHNma3ZsYmlqNWRxMCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/s1Dhasp2PHSlzO6vl8/giphy.gif

  • Yay! Just solved unwanted movement problem. I used has target instead of on shoot.

  • That's still not correct. You are not picking family members! All archers will move to the same GoodArmy instance, even if it's very far away and there are better targets nearby.

    And "Add target" action should not run on every tick. It's usually done once when the object is created, or on start of the layout.

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