Search Unity

Please help me when answers not working

Discussion in 'General Discussion' started by honzapat, Nov 4, 2017.

  1. honzapat

    honzapat

    Joined:
    Oct 3, 2015
    Posts:
    18
    Becuase if answers not working because of google captcha i posting it here
    Hi iam making and inventory pickup system
    my inventory script holding ammo and of player has the gun
    using System.Collections;
    using UnityEngine;

    public class WeaponScr : MonoBehaviour {

    // Use this for initialization
    public int ammo;
    public bool isOwn;

    }
    and pickup script that toggle the isOwn to true and another to add 40 rounds to ammo
    but it isnt working
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class Pickup : MonoBehaviour {
    public playerScript WeaponsScr;
    public GameObject WeaponItem;

    void Update()
    {
    // Rotate the object around its local X axis at 1 degree per second
    transform.Rotate(0,50*Time.deltaTime,0);
    }
    void OnTriggerEnter(Collider other) {
    WeaponsScr playerScript = WeaponItem.GetComponent("WeaponScr");
    playerScript.isOwn = true;
    Destroy(gameObject);
    }

    }
    can someone fix it and somehow explain me how to add 40 to the ammo varible?
     
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,619
  3. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,160
    I also recommend posting in the correct subforum. This belongs in scripting.
     
    Ostwind likes this.
  4. honzapat

    honzapat

    Joined:
    Oct 3, 2015
    Posts:
    18