Hi,
I am creating a game where you can throw physics objects at your opponent.
The projectiles seem to fall asleep from the moment when they are a bit further away.
The problem here is that I don’t have collision detection and there is no sleep() event where I could remove the object
or awake it again…
I really need a greater distance where my objects could fly to.
Is there a workaround for this?
Thanks!
Hello, and welcome to the Unity forum! 
I think in order to help, we’ll need to know more about your scene and how you’re creating and interacting with these objects.
What kind of object are you ‘throwing’ ?
Are the objects actually Asleep, or are you using that term loosely?
What does ‘throwing’ mean? How are you giving motion to these objects?
Does it have a Rigidbody?
Does the scene have gravity?
If you haven’t found many tutorials yet, the ones offered at http://www.unity3dstudent.com were quite useful to me in getting familiar with Unity. In particular, This One might be useful to you.
Hi,
Thanks for the help 
Sorry for my late reply I took some days off 
I have a character in my scene that throws projectiles using a script which holds a throwable prefab from my scene.
The throwable prefab has a rigidbody and a collision script that has to be automatically called when it hits something to destroy that instance of the prefab.
So when my character throws I create a new instance of that prefab and load another one in.
public void LoadNewProjectile()
{
projectile = (GameObject)Instantiate(projectilePref, this.transform.position, this.transform.rotation);
Physics.IgnoreCollision(GameObject.FindGameObjectWithTag("Player").collider, projectile.collider);
projectile.name = "projectile_" + projectilesThrown;
Debug.Log("Creating " + projectile.name);
projectile.rigidbody.detectCollisions = false;
bThrown = false;
}
If he throws this instance I use this function to move it in the right direction:
public void ThrowProjectile(Vector3 dir){
dir.Normalize();
Debug.Log("throwing " + dir);
vDir = dir;
bThrown = true;
projectilesThrown++;
projectile.rigidbody.detectCollisions = true;
Debug.Log("Throwing " + projectile.name);
projectile.rigidbody.useGravity = false;
projectile.rigidbody.isKinematic = false;
projectile.rigidbody.WakeUp();
Physics.IgnoreCollision(GameObject.FindGameObjectWithTag("Player").collider, projectile.collider);
StartCoroutine(SomeCoroutine(fReloadTime));
}
My update function does the following:
void Update () {
if(!bThrown) //not thrown parent to hand of object
{
projectile.transform.localPosition = handBone.position;
projectile.transform.localScale = new Vector3 (scaleSphere, scaleSphere, scaleSphere);
projectile.transform.rotation = Quaternion.identity;
}else{ //thrown so move to thrown direction
projectile.transform.localPosition += vDir * fSpeed * Time.deltaTime;
}
/*
if(Input.GetButtonDown("Fire2")) {
LoadNewProjectile();
}*/
}
This all works pretty well on short distance to the collider objects.
From the moment I throw from a further distance to any collider objects I dont have collision detection anymore and my objects
are just hanging still in the air (i use no gravity) at a specific distance from where they are thrown. I assume this is the sleeping part of my physics objects?
I want to add a rigidbody to have better collision detection on my projectile. I don’t want to make them kinematic because I would like to keep their collision detection. But I have my doubts about this because my objects have to become pretty kinematic because I will implement an auto aim function so they adjust their direction all the time…
Maybe physics not such a good idea for this situation because these are fast moving projectiles that need to change direction based on other character movement… Do you think I shouldn’t use the rigidbodies and use raycasting instead?
In that case I probably should raycast every time my object changes from direction?
Thanks,
Math
I don’t see anywhere in your code what you use to actually make the Rigidbodies move. If you used AddForce or any other Rigidbody options (velocity, constant velocity, etc), it should prevent the ridigbody from falling asleep. If you used translate without Gravity then yes, they are bound to fall asleep. Either use AddForce, or make them kinematic and translate them.
I move their localposition yes… I think it will be hard to use forces to get an auto aim on moving enemies?
If I put them kinematic I lose all collision detection which i definitely need…
Do I have to do raycasting every update to see if it hits?
No, just make it kinematic.