Hello out there,
the Controller of a Enemy-bullet is speeding the bullet up:
void Update ()
{
rb.velocity = transform.forward * speed;
}
In some scenes, the bullet travels at the correct speed, in others it is very very slow, but still a bit moving.
here the complete script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyBullet : MonoBehaviour {
[HideInInspector]
public float speed;
[HideInInspector]
public float makePlayerSlower;
[HideInInspector]
public float lifeTime;
[HideInInspector]
public ParticleSystem explosion;
float lifeTimer;
GameObject player;
Rigidbody rb;
bool mayDestroy = true;
bool wasStuck;
// Use this for initialization
void Start ()
{
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update ()
{
rb.velocity = transform.forward * speed;
wasStuck = false;
lifeTimer += Time.deltaTime;
if ((lifeTimer >= lifeTime) && mayDestroy)
Destroy(gameObject);
}
void OnTriggerEnter(Collider other)
{
if(other.CompareTag("Player"))
{
transform.parent = other.transform;
rb.isKinematic = true;
player = other.gameObject;
player.GetComponent<PlayerControl>().speedReduction = makePlayerSlower;
player.GetComponent<PlayerControl>().AddStickyBall(gameObject);
GetComponent<Collider>().enabled = false;
mayDestroy = false;
wasStuck = true;
}
else if(!other.CompareTag("Enemy"))
{
Destroy(gameObject);
}
}
void OnDestroy()
{
ParticleSystem explosionClone = Instantiate(explosion, transform.position, transform.rotation);
Destroy(explosionClone, 1f);
if(wasStuck)
player.GetComponent<PlayerControl>().RemoveStickyBall();
}
}
I am pretty shure, that i don’t change the transform of the bullet in any other scripts!
And i have now Idea…
(btw: if you have any advice for my in my way of scripting, please let me know! :D)
Thanks for reading and trying to help!
WbrJr