- Home /
Ai Targetting feet instead of my body
hey guys my ai is still shooting at my feet i know my pivot is over thare but i cant change it becouse it would wrek my player prefab i tried it so i tried getting the ai to shoot 1unit above my feet i looked at https://docs.unity3d.com/ScriptReference/Vector3.html for reffrence but it is still not working i used vector3 up as i understand it it would be 0,1,0.... so 1unit up i guess but it is still targetting my feet
enyone an idea how to fix this
i tried
transform.LookAt(target.transform.position += Vector3.up * Time.deltaTime);
..........................................................................
transform.LookAt(target,Vector3.up);
.............................................................................
Answer by jaca6767 · Jan 29 at 10:59 PM
You could add an offset to the script which controls the turret. Just add a vector3.up * height offset to whatever line contains the angle it's determining.
Some code to demonstrate this:
public Transform target;
public float heightOffset;
void Update()
{
transform.LookAt(target.position + (Vector3.up * heightOffset), Vector3.up);
}
Good luck, I hope this works in your multiplayer.
@jaca6767 can you plaese show me an example how to add the height? to the vector3.up * height
@jaca6767 yeah thanks works fine. reallly thanks i am so happy it finaly works.. can i maybe ask you an other thing i dont know if you have knowlage of strea$$anonymous$$g with photon onserializeview but in i am having problems with strea$$anonymous$$g and mostly reveiving layerweigts for my animations so if you are willing to help me with this please let me know ill show you what the problem is i alreddy asked it here on UA and some one told me what i did wrong but didnt explain how i can fix it i did try to get my answer on my own by googeling but i could not find anything on strea$$anonymous$$g layer weights only layer weights them self so please let me know.... thanks :D
@Wesley21spelde Sadly I have no experience with multi-player functionality. Could you mark this threads as solved?
Answer by SlamaBilliken · Jan 29 at 08:51 PM
You could make an empty Gameobject as a child of your character and move it to wherever you want the enemy to shoot, then use that object that as the enemy's target rather than the character itself.
hi yeah i forgot to mention i tried that but than i got problems with the network manager and other scripts becouse they couldnt find the player tag object anymore becouse it is a child thats why i wanted to try this.. anyw ay thanks for the tip ill try it again :D
Your answer
Follow this Question
Related Questions
C# Targetting Help 1 Answer
How to determine a "cone of influence" used for targeting an object. 2 Answers
What would be the best way to setup Target priority 1 Answer
AI Picking New Target After First Target Gets Destroyed 0 Answers
Hey I need an AI script for a character noticing nearby characters! 2 Answers