A* Pathfinding doesn’t work too well when you try to combine rigidbodies and/or constant force with it.
I just removed the rigidbodies and everything worked. Weird for me tho, can’t make the logic out of it.
/*
Hello again!
I’m feeling bad for selfishly asking for help on these forums when I can’t contribute much myself (I’m just not good enough), but hopefully some of you can help me out here:
*/
I’m making a FPS game with a tactical overhead view for controlling units in. When I switch to overhead view (switch cameras) which is about Y130 above the scene. Stuff started working again when I lowered the value to about 60 unity meters (Y) above ground.
What might be happening is that animations wont play (there are animation-dependant scripts). I’ve hooked OFF “Animate only if visible”, even if it shouldn’t matter (I can still see them).
What makes me think this is that the simple AI (search and destroy, using A* pathfinding) still actively searches for enemies and I can also control my playerobject from the tactical view.
Can anyone help?
Edit: using free version, not pro
“Animation” in this case refers to skinned mesh animation. Is this how the units are moved? If not, it is likely to be something to do with their control script. Can you think of anything that would make it dependent on the camera distance?
I’m pretty sure that’s not the case.
The AI should be fine without it.
I’ll have a look at it tomorrow (about late o’ clock here in Norway), dissect my scripts and formulate my problem better if I still can’t find a solution.
Cant for the life of me find what’s wrong. The scripts aren’t at dependant on the camera (besides the player assigning waypoints to the ‘good’ guys, which works just fine).
So unless anyone can take a good guess, or happen to know that it’s a limitation of the Unity engine, I will give this problem a short break while I work on networking for this game. It’s a part of my finishing bachelor project you see 
PS: I’m pretty sure this also happens when I walk a decent distance (off to some other rooms, perhaps 30m) away from the good AI.
Can you post the control/AI script you are using?
Sorry for the late reply.
I’ve tried to clean up the script a little but, still…
Adding what I guess is relevant.
Here we go:
Update:
if (Input.GetKeyDown(""+marineNumber))
{
GameObject.Find("Level_01").GetComponent("AssignNames").disableAllMarines();
cmndScript = transform.GetComponent("Command_Script");
cmndScript.Checker = true;
print("Checker :" + cmndScript.Checker);
}
FindEnemy();
if (CanAttackTarget())
{
targetRotation = Quaternion.LookRotation(marineTarget.transform.position - transform.position, Vector3.up);
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * 20);
}
if (lockedOn marineTarget CanAttackTarget())
{
Fire();
}
if (!lockedOn){
if (marineTarget CanAttackTarget())
{
TakeSights();
}
}
}
Functions:
function CanAttackTarget()
{
// Checks if target is within sightable range
if (marineTarget){
if (Vector3.Distance(transform.position, marineTarget.transform.position) > sightRange)
{
return false;
}
var hit : RaycastHit;
// Check for sight blocking objects
if (Physics.Linecast(transform.position, marineTarget.transform.position, hit))
{
if(hit.collider.gameObject.tag != "genestealer")
{
return false;
}
else {
return true;
}
}
return true;
}
}
///////////////////////////
function TakeSights()
{
animation.Play("assumeShoot");
lockedOn = true;
}
function Fire()
{
if (readyToFire == true CanAttackTarget()){
animation.Play("shootBurst");
readyToFire = false;
muzzleFlashing = true;
marineTarget.SendMessageUpwards("ApplyDamage", fireDmg, SendMessageOptions.DontRequireReceiver);
AudioSource.PlayClipAtPoint(fireSound, transform.position);
yield WaitForSeconds(0.1);
bolterLight.light.enabled = true;
muzzle.renderer.enabled = true;
yield WaitForSeconds(0.1);
muzzle.renderer.enabled = false;
yield WaitForSeconds(0.1);
muzzle.renderer.enabled = true;
yield WaitForSeconds(0.1);
muzzle.renderer.enabled = false;
yield WaitForSeconds(0.1);
muzzle.renderer.enabled = true;
yield WaitForSeconds(0.1);
bolterLight.light.enabled = false;
muzzleFlashing = false;
muzzle.renderer.enabled = false;
yield WaitForSeconds(Random.Range(0.7, 1.3));
readyToFire = true;
}
}
function FindEnemy()
{
if (searchReady)
{
searchReady = false;
var waypoints: GameObject[] = GameObject.FindGameObjectsWithTag("genestealer");
var closestDist = Mathf.Infinity;
for (waypoint in waypoints) {
var dist = (transform.position - waypoint.transform.position).sqrMagnitude;
if (dist < closestDist) {
closestDist = dist;
marineTarget = waypoint;
}
}
yield WaitForSeconds(0.2);
searchReady = true;
}
}
It seems that the enemies (related to the same problem) stop attacking (or at least are severely bugged) during multiplayer sessions.
And it’s a skinned mesh, yes (I think?).
A fully modelled character animated with IK in maya and exported with baked animations into fbx.
Seems that units stop attacking when the number of units gets too high too. This is really bugging me!