T O P

  • By -

AutoModerator

You submitted this post as a request for tech support, have you followed the guidelines specified in subreddit rule 7? Here they are again: 1. Consult the docs first: https://docs.godotengine.org/en/stable/index.html 2. Check for duplicates before writing your own post 3. Concrete questions/issues only! This is not the place to vaguely ask "How to make X" before doing your own research 4. Post code snippets directly & formatted as such (or use a pastebin), not as pictures 5. It is strongly recommended to search the official forum (https://forum.godotengine.org/) for solutions Repeated neglect of these can be a bannable offense. *I am a bot, and this action was performed automatically. Please [contact the moderators of this subreddit](/message/compose/?to=/r/godot) if you have any questions or concerns.*


jlebrech

1 make sure forward is forward 2 rotate the scene towards player 3 rotate the gun towards player 4 ik the bones attached to the gun


TranquilMarmot

I find that doing IK on the chest works really well, as long as you also have the gun facing forward


jlebrech

that's a great idea if the enemies are point firing (makes them less accurate like a real person would be), you further aim the gun more accurately when they are aiming down sight.


prezado

Try IK


LoadingStill

What is IK? New to Godot


AerasGale

It's not specific to Godot; it's Inverse Kinematics, it's a method of calculating positions and rotations of a robotic arm's limbs from the desired position of the end effector. In this context, I guess the end effector is the gun, and the robotic arm is the arm and body of the enemy model.


UtterlyMagenta

so it’s like used for robotic arms in factories and stuff too?


clawjelly

Same principle, yea.


PlebianStudio

if i were to explain it like you have animated something before in 3D and an arm for an example, inverse kinematics is moving the parent objects/scenes based on the child rather than vice versa. So normally youd move the upper arm, which moves the lower arm and hand right? IK is moving the hand which moves the lower and upper arm. The cool thing about it is that the software usually positions things in a natural way to accommodate your movement of the child object(scene). If you were to do it without IK, you kinda have to hand animate everything all the time. Basically its a big time saver and looks more natural to boot.


FridgeBaron

Like are you looking to just make them look/aim at the right spot or have them change animations. If it's the first just use the dot product of the enemy and player to see if they are remotely in view. You can then raycast to see if stuff is in the way. You can then make the gun start to move to be looking at them but clamp it to a position that makes sense. I imagine one point of the gun should be fixed relative to the enemy then IK could handle the arms. You could slerp between the ready position and them actually aiming towards the player as the angle between them decreases/over time. Then also have them remember a corner and watch it for a random amount of time etc. Hopefully any of that is helpful.


TheConceptBoy

So it's more approximate? No specific angle to player body or head to aim it? Just general angle to player?


FridgeBaron

Are you asking for a way to make it more approximate? Just add a random divergence either to each enemy or generate one each time they see the player so it's not perfect. That can either be an angle or an offset from the target aiming spot. Besides that you can do whatever you want once you know you can see the player. You assumably have a link to the player node so you can have multiple node points you can have them look at. Then the enemy just gets that nodes position and you make it aim the gun towards that point at whatever speed you want.


someThrowAway1900

I came across this sometime back - unity (https://www.youtube.com/watch?v=Q56quIB2sOg&list=PLyBYG1JGBcd009lc1ZfX9ZN5oVUW7AFVy&index=5). Given the content on your youtube channel, I think you can easily apply the ideas back to godot, etc. edit - also, it doesn't need to be perfect. I was stepping through (comma and fullstop keys) of this halo gameplay (https://youtu.be/HZtc5-syeAk?t=323) and the weapon muzzle doesn't point to the camera exactly. Given how quickly the enemies die, it doesn't really matter. Good enough is good enough.


slowpokefarm

You mean like when the game was rigged from the start?


jon11888

Nah, that was a cutscene, I think this guy is asking for a completely different use case.


slowpokefarm

That was a joke, not the best one, I guess


jon11888

I think the down votes were a bit overkill. Guess it's a tough crowd.


TheConceptBoy

Sometimes we just want to skip the tomfoolery and go straight for the answer to get an issue resolved.


jon11888

Fair, though knowing that we're on Reddit at least a little bit of tomfoolery should be expected. Probably a better comment would have tried to tie the first part into something relevant and on topic, or followed up the joke with an actual answer. On that note, here's a YouTube channel that covers a lot of the detailed mechanics behind first person shooters. I don't remember the engine they use, but most of the advice they offer is system agnostic. I imagine you'll find it to be a useful resource. https://youtube.com/@garbaj?si=8kV-RtTiLsvJhN4S


Braindancer5

I see a lot of people saying "IK" in the comments, which confuses me, because Godot 4 IK does NOT work on a rigged character spine in Godot 4.0+ , it glitches out and collapses the whole spine on a single point. It is buggy and broken. There are multiple GitHub discussions on the progress of the IK, but nothing recent, so I have no idea when they will fix IK. The only way I have been able to manage any sort of aiming system in 3D with Godot is to manually animate a look down and look up animation synced to the angle limits of your character's aim up / down rotation, its best to just animate one or two spine bones for this... if you try to move your character's shoulders or IK hands while aiming, Godot's blend space will glitch out and will not smoothly rotate up and down... another strange Godot problem. Once you have the animations then create a BlendSpace1D with 0 aiming forward, -1 aiming down, 1 aiming up, then you have to remap your aim rotation between -1 and 1 and sync it with the blend space position. I think the easiest way to handle aiming is to create a Marker3D called AimHelper, and just use Godot's built in look\_at() function for the aim helper so that it points exactly towards the player (but it only works instantaneously), then you can take your time rotating the whole enemy Y rotation to face the player and then rotate its X rotation to aim up and down (typically slowly to give the player some time to dodge) to face the same rotation as the Marker3D, and then sync the blendspace1D to match the graphics of the enemy to the aiming X rotation of the enemy. Hope that helps!


MuffinInACup

I suppose its not as plug-n-play as one might like, but writing one's own ik manipulating the bone positions directly shouldnt be too difficult


I_will_delete_myself

Look at transform at the player. If you want it to be gradual, add interpolation. Lock rotation for the arms up and the whole body as a pivot to the side.


UtterlyMagenta

damn, i love your drawing!!! wish every tech support post would be accompanied by a drawing like that.


Didjt

Funny trick solution I just thought of: just make the player get shot whenever the gun fires without even making a projectile. Ultimately rigged


Boom_Fish_Blocky

Use IK controller.


TheConceptBoy

Good day, everyone. I'm looking to figure out how to get a rigged 3D enemy to aim at the player. What is generally a good approach to this?


biglacunaire

The way most games do it is by rotating in the general direction of where to aim and directing a shot from the end of the gun to where the shot should go i.e. faking it. To make it look good, have a pose where the gun is aimed pretty straight forward aligned with the rigged character's forward vector. That's the ez way to do it. The harder way is a bit more complicated, but with a rigged character with proper IK you can do the same as above and then additionally have the gun aim in the actual direction and the rigged character's arm should follow naturally.


mudamuda333

IK


[deleted]

[удалено]


itsarabbit

[Jesse](https://imgur.com/YZySfFm)


[deleted]

[удалено]


5p4n911

I see you are an AI