I'm controlling the spine of the enemy with an SkeletonIK3D, so it can "look" at the player. However, it doesn't seem to be looking at the player properly and I don't know why. Whenever the player the goes at a high place, the enemy looks down. Whenever the player goes to a low place, the enemy lows high. I even tried to invert the tracking in code to solve the problem but, it didn't work; it just behaved the same way. Does anyone know the solution to this problem? I'll give video examples.

Here's a screenshot of the enemy in the viewport.

Also, here's the code:

chest_ik_target.look_at(Vector3(player.global_position.x,player.global_position.y,player.global_position.z))

Does anyone know the solution to this problem? It has been holding back for a long time and I've tried finding various solutions on my own.

  • xyz replied to this.
    • Edited

    Audiobellum look_at() points node's local -z axis towards the target. If you want to point +z axis, you can pass use_model_front argument when calling look_at(). If you want to point an axis other than z, you'll need to write your custom look at function

      xyz
      Okay. So I tried using the use_model_font argument and it turned the spin of the enemy's rig backward.

      However, I discovered that's the same problem that I had when I set Override Tip Basis to true. So I kept the use_model_font argument true while also turning the Override Tip Basis to true; the end result was something that was incredibly close to what I wanted to accomplished.

      The only problem is that I don't understand my own situation and that I can see still the problem when I'm not running the game if I press Play IK.

      Is there any other solution to the problem that doesn't I can understand? Better yet, is there any standard practice I can use to avoid ruining into this problem in the future? For example, could I get any types of exporting/importing that would be helpful?

        Gowydot I was using Godot 4.2. Is there any feature in Godot 4.3 that can help me? Also, is it safe to start making games with the the Godot 4.4 beta?

          Audiobellum
          from Reddit user:

          users no longer need to rely on specific bone structures and arbitrary layouts; this new tool allows for angle limitations, forward axis settings, etc., and is specialized for making a 3D character model look in the target direction

          I guess this is a new feature specifically for 4.4. You can just soft migrate your project to 4.4 and test it out.

          is it safe to start making games with the the Godot 4.4 beta?

          No but you can work on other parts of the game first until 4.4 stable-enough release, that's what I would do.

            Gowydot I went on the official website to find the beta but, it isn't there. Can you show me where to find it?

              I have the exact same problem, I'm trying to solve this since yesterday. It seems like nothing ever does what I want. I've already tried multiple models. Looking at the z axis, -z axis, rotating 180 degrees. The look_at functions always does the opposite of what's supposed to do.

              I'm this attempt I just made a BoneAttachment3D attached to the head bone and checked the Override Position option. But I've also tried directly accessing the bones in Skeleton3D, same thing, it just looks to the opposite way.

                dookiedon
                Also, there's two "look_at" functions here. The first one works correctly. The first one is making the entire body face the player (only horizontally), then the second is my attempt of making only the head follow the player. The first one works just fine, the second doesn't.

                @dookiedon @Audiobellum

                Try using looking_at(). I have these links saved, maybe they'd help. (for godot 4.3 and lower)

                Smooth rotation
                Basis.looking_at vs Transform3d.looking_at

                Also, You'd need to convert your target global_position to use with skeleton's local position. Something like

                var target_global_position = target.global_position
                var target_local_position = to_local(target_global_position)

                then use the target_local_position with your looking_at(). for example:

                ...looking_at(target_local_position.....etc..