Search Unity

gun shooting script c#

Discussion in 'Scripting' started by XxSaiFxX, Jan 11, 2014.

Thread Status:
Not open for further replies.
  1. THEGAMINGGAMERGUY

    THEGAMINGGAMERGUY

    Joined:
    Jan 20, 2021
    Posts:
    6
    can someone send me a script that shoots Raycasts instead of projectiles plz
     
  2. THEGAMINGGAMERGUY

    THEGAMINGGAMERGUY

    Joined:
    Jan 20, 2021
    Posts:
    6
    thx I got it working but now no matter any way I turn the gun it shoots out the right side plz help me
     
  3. THEGAMINGGAMERGUY

    THEGAMINGGAMERGUY

    Joined:
    Jan 20, 2021
    Posts:
    6
    it keeps shooting out the right side idk why no mater which way I turn the gun it shoots out the right side
     
  4. kamalaswal40

    kamalaswal40

    Joined:
    Feb 9, 2021
    Posts:
    4
    USE THIS AND PLEASE HELP ME TO MAKE ENMY PLEASE
    using UnityEngine;
    public class FIRING : MonoBehaviour
    {
    public float damage = 10f ;
    public float range = 100f;
    public Camera fpsCam;
    void Update()
    {

    if(Input.GetButtonDown("Fire1"))
    {
    Shoot();
    }
    }
    void Shoot()
    {

    RaycastHit hit;
    if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward , out hit ,range))
    {
    Debug.Log(hit.transform.name);
    }
    }

    }
     
  5. jeronightyt

    jeronightyt

    Joined:
    Feb 10, 2021
    Posts:
    2
    i need help is because when i press mouse bottom the bullets go up upload_2021-2-10_13-42-16.png
     
  6. jeronightyt

    jeronightyt

    Joined:
    Feb 10, 2021
    Posts:
    2
    yo meam that alwais when i click the bullets go up
     
  7. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,749
    Please stop posting fragments of text to seven-year-old scripts. It is against the forum rules.

    If you have a question, post your own post... it's FREE!

    Before you post a question, please read this:

    How to report your problem productively in the Unity3D forums:

    http://plbm.com/?p=220

    How to understand errors in general:

    https://forum.unity.com/threads/ass...3-syntax-error-expected.1039702/#post-6730855

    If you post a code snippet, ALWAYS USE CODE TAGS:

    How to use code tags: https://forum.unity.com/threads/using-code-tags-properly.143875/

    Help us to help you.
     
  8. Eliz109

    Eliz109

    Joined:
    May 15, 2021
    Posts:
    1
    Hi I need help


    1. using UnityEngine;
    2. using System.Collections;

    3. public class ShootDemo : MonoBehaviour
    4. {
    5. public Rigidbody projectile;
    6. public float speed = 20;

    7. // Update is called once per frame
    8. void Update ()
    9. {
    10. if (Input.GetButtonDown("Fire1"))
    11. {
    12. Rigidbody instantiatedProjectile = Instantiate(projectile,transform.position,transform.rotation)as Rigidbody;
    13. instantiatedProjectile.velocity = transform.TransformDirection(new Vector3(0, 0,speed));
    14. }
    15. }
    16. }


      I did this then its asking me for projectile
     
  9. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,749
    Yes, yes, you do need help.

    Go read the post directly ABOVE your post please.
     
    eses likes this.
Thread Status:
Not open for further replies.