- Home /
Game 2x speed object pass through other
I am making a basic TD game with a fast-forward feature. When i press the fast-forward button, the game speeds up, but the bullet that the turret shoots goes through the enemy (object).
This is the code for the bullet:  void OnTriggerEnter(Collider other){
 
                    //-- Development Test
     if(Time.timeScale == 2){//If fast forward
         if(other.tag == "Enemy" || other.tag == "Enemy 2"){//if hit enemy
             Time.timeScale = 0;//pause game
             Debug.Log (other.collider.gameObject.name);//Debug enemy name
         }
     }
     //--
     
     if(other.tag == "Enemy" || other.tag == "Enemy 2"){//if hit enemy
         other.collider.gameObject.GetComponent<EnemyHealth>().setHealth (Damage);//reduce health
         Destroy(gameObject);//destroy bullet
     }
 }
 And this is how the turret aims:  if(myTarget){//if turret has a target
 
                        if(Time.time >= nextMoveTime){
             //CalculateAimPosition(myTarget.position);
             turretBall.LookAt(myTarget);//lookat the target
         }
         
         if(Time.time >= nextFireTime){//if can fire
             FireProjectile();//fire bullet
         }
     }
 In the Development Test section (of the bullet script), the bullet doesn't "collide" with the enemy (or it doesn't detect it). How would i detect if the bullet collides with an enemy when the game is at 2x the speed?
Is your projectile rigidbody based? If so, you need to learn how physics collisions work :)
Answer by 73cn0109y · Jul 17, 2013 at 02:36 AM
I actually looked more into physics collision and implimented the "DontGoThroughThings" script, (http://wiki.unity3d.com/index.php?title=DontGoThroughThings#C.23_-_DontGoThroughThings.js), and slightly modified it and it works fine now :) Thankyou.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                