Why the bullets have no force they are not moving forward and the rotation is also not set fine ?

Screenshot of the bullets when firing :

The bullets are stay still and they are standing.

This screenshot show the Fire Point inspector position rotation scaling :

And a screenshot of the bullet prefab settings :

Last screenshot show the Shooting gameobject inspector settings :

And the script Shooting :

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

public class Shooting : MonoBehaviour
{
   [SerializeField]
   private Transform[] firePoints;
   [SerializeField]
   private Rigidbody projectilePrefab;
   [SerializeField]
   private float launchForce = 700f;

   public void Update()
   {
       if (Input.GetButtonDown("Fire1"))
       {
           LaunchProjectile();
       }
   }

   private void LaunchProjectile()
   {
       foreach (var firePoint in firePoints)
       {
           Rigidbody projectileInstance = Instantiate(
               projectilePrefab,
               firePoint.position,
               firePoint.rotation);

           projectileInstance.AddForce(firePoint.forward * launchForce);
       }
   }
}

How can I make that it will not leave a trail of bullets behind ?
And why the bullets are standing and not in the direction of the Fire Point ?

Are you sure this compiles? `projectileInstance.AddForce’ doesn’t make any sense to me. AddForce is called on Rigidbodies, but you’re calling it on a GameObject. Unless you’ve overloaded Instantiate to return a rigidbody, I don’t see how this code would compile without giving you errors.

1 Like

I guess I messed it all.
But I’m not getting errors.

The projectilePrefab have a Rigidbody.
In the screenshots in my question you can see the Bullet prefab screenshot this is the projectilePrefab.

Maybe I didn’t understand. But I’m not getting any errors.

Why do you have isKinematic set to true on the bullet prefab rigidbody? Please read what it does.

https://docs.unity3d.com/ScriptReference/Rigidbody-isKinematic.html

This is one reason I get frustrated at seeing “var” in forum posted code.

1 Like

Right I should change the var to Rigidbody

But try disabling isKinematic. I believe that is the source of your problem.

1 Like

I tried it before disabling the is kinematic make the bullets to fall down.

Yeah, because you have gravity enabled. That is the adjacent checkbox.

Again:

So by checking isKinematic you are making it so forces do not affect the bullet. Why would you think AddForce would then move the bullet? You are adding a force to a rigidbody that you’ve told to ignore any force.

If you want it to use isKinematic you can’t move it using the physics system. You need to update the transform.position each frame.

1 Like