Third person controller moving backwards when shooting
Hello Everyone, Here is my problems; i use standart assets Third Person Controller and put a sphere object (scale 1, 1, 0 ) just front of its feet. This object is acting as spawn point for instantiated object (projectile scale 0.5, 0.5, 0) which is moving forward and another cube object (scale 1, 1, 0) infront of it is acting as collider to destroy those instantiated objects. basicly controller shoots and collider destroys. Both objects are moving infront of and with controller.
1) when i shoot the controller moves backwards. the spawner and collider or projectiles dont touch controller but controller moves backwards after each shoot. 2) some projectiles pass through , inside the bloker cube object, some got destroyed. any idea to fix these 2 issues? Thanks.
scripts i use;
1) for projectile :
void Update() { GetComponent().AddForce(transform.forward * 250); }
2) shoot button:
public Transform sphere; public GameObject projectile;
public void pressed()
{
Instantiate(projectile, sphere.position, sphere.rotation);
}
3) Bloker cube Destroy script;
public class Bloker : MonoBehaviour { public GameObject projectile;
void OnTriggerEnter(Collider projectile)
{
if (projectile.tag == "projectile")
{
Destroy(GameObject.FindGameObjectWithTag("projectile"));
}
}
Your answer
Follow this Question
Related Questions
Adding different values to randomly created objects 0 Answers
Instantine - none collider 0 Answers
Who collided first 0 Answers
Make a collision check when spawning with Instantiate 1 Answer