Rotate Towards

Discussion in 'How Can I...?' started by 5petersonzachary, May 3, 2020.

  1. 5petersonzachary

    5petersonzachary Serious Boxer

    Joined:
    Jan 23, 2016
    Messages:
    569
    Likes Received:
    169
    I am using the rotate towards node to get an enemy to rotate towards the player. The problem is when I add the node and select the character for the asset I want to follow, the enemy rotates the opposite direction as the player. If I move the character left the enemy rotates right and if I move the character down the enemy rotates up. Anyone know how to solve this issue?
     
  2. sws

    sws Boxer

    Joined:
    Apr 20, 2020
    Messages:
    26
    Likes Received:
    6
    I have set up a simple 3D game to test the rotate towards and it is working correctly for me. I don't know the "correct" solution to your problem, but a quick and dirty answer that might work for you is to double click on the Rotate Towards node to open the script.
    Towards the bottom, find the line that says: let tp = targetEnt.position();
    After that line, add this: tp.x = -tp.x;
    If that doesn't completely solve it, try this instead:
    tp.x = -tp.x;
    tp.z = -tp.z;
    In my game, this code caused the enemy to rotate opposite of my character, so it might correct your enemy movement.
     
  3. sws

    sws Boxer

    Joined:
    Apr 20, 2020
    Messages:
    26
    Likes Received:
    6
    Don't know why I didn't think of this earlier, but this might be a better solution. Double click on the enemy in your Asset Library to open the node map. Click on the 3D Model node.On the right side of the screen, scroll down to Rotation and change Y to 180.
     
  4. 5petersonzachary

    5petersonzachary Serious Boxer

    Joined:
    Jan 23, 2016
    Messages:
    569
    Likes Received:
    169
    I'll try the code because I have already tried rotating the 3d model
     
  5. 5petersonzachary

    5petersonzachary Serious Boxer

    Joined:
    Jan 23, 2016
    Messages:
    569
    Likes Received:
    169
    This doesn't work either it still rotates the opposite way. Thanks anyways :)
     
  6. landofgreendev

    landofgreendev Boxer

    Joined:
    Nov 9, 2018
    Messages:
    85
    Likes Received:
    18
    Did you find the answer to this? I'm having the same issue
     

Share This Page