When using ik to llok at target for some reason if the target is moving and coming from behind the player head will not rotate completely to the side

using System.Collections; using UnityEngine;  [RequireComponent(typeof(Animator))] public class LookAtTarget : MonoBehaviour {     public Transform lookObj = null;     public float finalLookWeight;     public float weightDamping = 1.5f;      protected Animator animator;      void Start()     {         animator = GetComponent<Animator>();     }      //a callback for calculating IK     void OnAnimatorIK()     {         if (lookObj != null)         {             Vector3 flattenedLookAtVector = Vector3.ProjectOnPlane(lookObj.position - transform.position, transform.up);             float dotProduct = Vector3.Dot(transform.forward, flattenedLookAtVector);             float lookWeight = Mathf.Clamp(dotProduct, 0f, 1f);             finalLookWeight = Mathf.Lerp(finalLookWeight, lookWeight, Time.deltaTime * weightDamping);             float bodyWeight = finalLookWeight * .5f;              animator.SetLookAtWeight(finalLookWeight, bodyWeight);             animator.SetLookAtPosition(lookObj.position);         }     } } 

When an object that is rotating around my player the head will rotate looking at the target to the side if the target that is rotating around coming from the front of the player but if the target is coming from behind the player will not rotate the head completely like when the target is coming from the front.

I tried to switch the line :

float lookWeight = Mathf.Clamp(dotProduct, 0f, 1f); 


float lookWeight = Mathf.Abs(dotProduct); 

When using Abs instead Clamp it fix the problem but than the looking at smoothing is less smooth when using Clamp. It is smooth but not as with Clamp.

This screenshot is when the basketball the object the player is looking at coming from the front to the back the player is looking at it even when it’s on the side which is good and what I wan it to behave like.

Basketball is rotating around the player in this frame is when the basketball came from the front

In this screenshot the basketball is keep rotating around the player and coming moving forward from behind from the other side and for some reason when it come from behind the player start looking at not when the basketball is on the side but a bit more when the basketball is a bit more in front of the player :

Basketball is coming from behind but the player detect the basketball only when the basketball get much more to the front of the player.

Why the transform is not looking at the target?

The goal is to make smooth rotating look at.

The parent object is my character have a Rigidbody.

The script is attached to the character parent. I make a reference to the character child name head.

I have a cube as the target the cube is rotating around the character with random height.

The character is never looking at the cube. I tried to change from LateUpdate to Update I tried to add a child of the head empty gameobject and reference the empty gameobject but still the character head is not rotating to the target.

using System.Collections; using System.Collections.Generic; using UnityEngine;  public class SmoothLookAt : MonoBehaviour {     public Transform leadObj;     public Transform lookAtTarget;     public float damping = 6;     public bool smooth = true;       private void LateUpdate()     {         if (lookAtTarget)         {             if (smooth)             {                 // Look at and dampen the rotation                 var rotation = Quaternion.LookRotation(lookAtTarget.position - leadObj.position);                 leadObj.rotation = Quaternion.Slerp(leadObj.rotation, rotation, Time.deltaTime * damping);             }             else             {                 // Just lookat                 leadObj.LookAt(lookAtTarget);             }         }     }      private void Start()     {         // Make the rigid body not change rotation         if (leadObj.GetComponent<Rigidbody>() != null)             leadObj.GetComponent<Rigidbody>().freezeRotation = true;     } } 

It seems to be working if I reference the head directly as leadObj and inside LateUpdate the problem is that I have to set the damping value to 260.

Why I need to set the damping value to be so high ?

And how can I make that the head will rotate to the target with automatic speed depending on the target moving speed ? So if I don’t set any damping value for example 0 or null it will automatic calculate the needing speed to rotate facing the target ?

I see now another problem. If I set the damping value to 100 for example the character head is stuttering the head will look at the target but will stuttering. I want that if the damping value is 100 or lower than rotate the leadObj with a delay facing the target. Something like when a turret is rotating facing a missile and if the missile is moving too fast the turret is rotating with some delay because he rotate slower. How can I do it ?

This is working using Lerp. But why if I set for example the duration value to 0 it’s not affecting the speed of the leadObj rotation ?

The leadObj keep rotating same speed facing the target even if the duration is 0.

What am I missing ?

using System.Collections; using System.Collections.Generic; using UnityEngine;  public class SmoothLookAt : MonoBehaviour {     public Transform leadObj;     public Transform lookAtTarget;     public float duration;     public bool smooth = true;      private float t = 0.0f;      private void Start()     {         // Make the rigid body not change rotation         if (leadObj.GetComponent<Rigidbody>() != null)             leadObj.GetComponent<Rigidbody>().freezeRotation = true;     }      private void LateUpdate()     {         if (lookAtTarget)         {             if (smooth)             {                 t += Time.deltaTime;                 float s = t / duration;                  // Look at and dampen the rotation                 var rotation = Quaternion.LookRotation(lookAtTarget.position - leadObj.position);                 leadObj.rotation = Quaternion.Lerp(leadObj.rotation, rotation, s);             }             else             {                 // Just lookat                 leadObj.LookAt(lookAtTarget);             }         }     }  } 

Why when I move the transform closer to the target by dragging it in the editor in the scene view the target start stuttering and moving back?

The script is attached to a transform that move to a target and than when reaching the target the transform become child of the target.

The script is working fine as it is now but if I drag with the mouse in the editor in the scene view the target to the moving transform while the transform is already moving to the target then the transform start stuttering and even moving back a bit like pushed back some forces pushing it back maybe because I’m using lerp in lines 55,56 ? I want to use lerp but maybe it’s making the problem?

Second if I move the target away from the transform instead trying to chase me and reaching me its doing this problems again.

I want that if I’m dragging and make the target closer to the moving transform than just keep the transform moving to the target and become child when they reaching each other and if I drag the target away from the transform make the transform try to chase me reach me and become child too.

using System.Collections; using System.Collections.Generic; using UnityEngine;  public class MoveToTarget : MonoBehaviour {     public enum TransitionState     {         None,         MovingTowards,         Transferring     }      public Transform destinationTransform;     public float speed;     public float lerpTime;     public bool isChild = false;      public AnimationCurve curve = AnimationCurve.EaseInOut(0.0f, 0.0f, 1.0f, 1.0f);     public Transform start;     public Transform end;     public float duration = 10.0f;     private float t;      private Transform originTransform;     private float timer;     private TransitionState state = TransitionState.MovingTowards;     private Vector3 originTrans;      void Start()     {         t = 0.0f;          curve.postWrapMode = WrapMode.PingPong;         originTrans = transform.position;     }      void Update()     {         switch (state)         {             case TransitionState.MovingTowards:                 var v = destinationTransform.position - transform.position;                 if (v.magnitude < 0.001f)                 {                     state = TransitionState.Transferring;                     originTransform = destinationTransform;                     timer = 0;                     return;                 }                 Vector3 moveDir = v.normalized;                 //transform.position += moveDir * speed * Time.deltaTime;                 t += Time.deltaTime;                 float s = t / duration;                 transform.position = Vector3.Lerp(originTrans,                     destinationTransform.position, curve.Evaluate(s));                 break;              case TransitionState.Transferring:                 timer += Time.deltaTime;                 this.transform.position = Vector3.Lerp(originTransform.position, destinationTransform.position, timer);                 if (timer >= 1.0f)                 {                     this.transform.parent = destinationTransform;                     isChild = true;                     state = TransitionState.None;                     this.enabled = false;                     return;                 }                 break;              default:                 this.enabled = false;                 return;         }     } } 

(Unity 3D) How to make Player consistently jump *to* a specific target rather than *towards* it?

I’m trying to make it so if my player hits "E" then they jump precisely to a specific target. The current code results in player jumping towards the target but not really making it there.

I’ve tried adjusting forceMultiply and ForceMode and adding an offset but I just can’t get a result that simply consistently launches the player’s rigidbody rb towards the anchorPoint position.

The code I have is:

private void Update() {     if (Input.GetKeyDown(KeyCode.E))     {         tryGrabbing = true;     } }  private void FixedUpdate() {     if (tryGrabbing)     {         rb.AddForce(anchorPoint.transform.position * forceMultiply, ForceMode.Impulse);     } } 

Thank you for any help!!

Is a target pushed into a wall by a spell effect subject to collision damage?

Some spells can push the target X feet away (like thunderwave, which pushes 10 feet away on a failed save). I was wondering what happens if the target, while being pushed, encounters a wall or other rigid object. Does it take (bludgeoning) damage? To me it seems logical that it would: it is like falling, sudden force applied to a creature due to encountering resistance from an object.

I couldn’t find any rules about this in the Player’s Handbook nor online.

What do you do when a spell or something says that the target needs to do a saving throw without a number for the throw? [duplicate]

For command, it states, "The target must succeed on a Wisdom saving throw or follow the command on its next turn" without any context to how high the target needs to roll for it to succeed. What does the target need to roll to succeed that saving throw? Is the number specific for command or is it the same for all spells like this? I’d like to get all the info I can for this.

Can a bolt-action hunting rifle (long arm), be fired when target is at arm’s length? [closed]

Yesterday, I was running my homebrew system (D100), with a friend and one of my nephews over Discord. It was a zombie apocalypse theme. The situation occurred, when my friend (carrying a bolt-action hunting rifle), was rushed by an ‘infected’, and it did a ‘claw strike’, and missed. It was my friend’s turn next. He wanted to do a scoped shot with the bolt-action hunting rifle, but I informed him that the infected was at arms length (too close).

He said he still wanted to fire his rifle (which I considered a long arm), but I said the target was too close. I gave him the option of using the rifle stock to make a melee attack, but he still wanted to fire the rifle. The ‘discussion’ went on for some time, with me trying to explain to the 2 of them (a third one soon joined in), all saying that he could fire the rifle, even if the target was at arm’s length (1 to 1.5ft away?) Hunting rifle stats: Most full-size, bolt-action hunting rifles weigh more or less eight pounds, are around 41 to 42 inches long and have 22- to 24-inch barrels. This means that with scope, sling and everything hunt-ready, the typical rifle rig weighs-in at around nine pounds. So from above, the rifle needs 3.5 feet ‘clearance’ to fire.

I was telling my friend that because the target was so close, and the rifle was a ‘long arm’, he didn’t have enough ‘space’ to bring it to bare, and point the barrel end at the target (it was in his face’, almost).

Any advice would be most appreciated concerning this above situation.

Does the light from Branding Smite persist after the target dies? [duplicate]

The players were exploring Castle Ravenloft. A trap separated the human paladin from the rest of the party and placed him in a deep pit with no light source. In looking for a way out, he accidently released and then began to fight a wight. This was initially quite bad as he was attacking with disadvantage, while the wight (with darkvision) was attacking twice with advantage. The paladin remedied this by casting Branding Smite, hitting the wight, and making it glow.

Branding Smite, emphasis mine:

The next time you hit a creature with a weapon attack before this spell ends, the weapon gleams with astral radiance as you strike. The attack deals an extra 2d6 radiant damage to the target, which becomes visible if it is invisible, and the target sheds dim light in a 5-foot radius and can’t become invisible until the spell ends.

After two more hits and some Divine Smite, the wight was dead. The paladin wanted to hack off a piece of the glowing wight corpse and use it as a light source to help him climb out of the pit (spell duration is Concentration – 1 minute, the paladin needed three rounds to climb out of the pit). I hesitated, because when the wight ceased to be undead and became just dead, it was transformed from a creature into an object and was thus no longer a valid target of the spell.

Ultimately I ruled that one thing is a valid target for casting the spell itself, another is the persistent effects of the spell, and that the corpse would go on glowing for the duration. However, I would like to know RAW for this and whether all the effects of the spell would cease when the wight was killed.

Related: Is a target suppressed or removed when the target becomes invalid?. Superficially this might appear like a duplicate of my question. However, the question there is about the dominate person spell when the target is no longer a Humanoid because of polymorph. Obviously dominate person cannot continue to work if the target is no longer a Humanoid to dominate, but a dead wight could still continue to be a source of light. I feel like that question is a different situation than Branding Smite where the 2d6 radiant damage is the spell itself and the light produced is a persistent effect of the spell. Maybe the answer is not different, but I believe the question is different enough that it stands on its own.

Also, although not a reason to say that this is not a duplicate, I am unsatisfied with the accepted answer to that question being based on a Crawford tweet.

Will a target being apatic after broken haste still remain apatic after beeing downed? [closed]

We had a strange situation in a fight,

and I really side with my DM here who denied it, but the question still remains:

  1. a character is hasted
  2. the concentration breaks, character is in an lethargic state
  3. character gets knocked down before his next turn
  4. the target is no longer a willing creature (?), also it’s status alignments should end when knocked unconscious
  5. the character receives healing and gets back up on his feet -> will he still be lethargic?

I should note that we assume a character would not remain unconscious even after beeing healed / stabilized for simplicity reasons. ( I heard some groups play it this way, unsure about the correct rulings here )