Home Unity

Unity shooting problems

Offline / Send Message
Pinned
Problem:My bullet just bounces off the wall every time I shoot and hit a wall,any fix? 
My code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BulletController : MonoBehaviour
{
    public float moveSpeed, lifeTime;

    public Rigidbody theRB;


    // Start is called before the first frame update
    void Update()
    {
        theRB.velocity = transform.forward * moveSpeed;

        lifeTime -= Time.deltaTime;

        if (lifeTime <= 0)
        {
            Destroy(gameObject);
        }
    }

    private void OnTriggerEnter(Collider other)
    {
        Destroy(gameObject);
        
    }
}

Replies

Sign In or Register to comment.