- Home /
Question by
fraubolat · Jun 19, 2020 at 03:08 PM ·
scripting problemraycastingswitchingreloading
my switch script isnot working the way it should even though i have no errors
every time is witch from the shotgun to the ak or the opposite way one of the guns donot shoot or both donot shoot and i am pretty sure that my guns script is working fine here is the switch script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class realswitchweapon : MonoBehaviour
{
[SerializeField] GameObject ak;
[SerializeField] GameObject SHOTGUN;
void Start()
{
SHOTGUN.SetActive(false);
}
void Update()
{
if(Input.GetKeyDown(KeyCode.Alpha1))
{
SHOTGUN.SetActive(true);
ak.SetActive(false);
}
if (Input.GetKeyDown(KeyCode.Alpha2))
{
ak.SetActive(true);
SHOTGUN.SetActive(false);
}
}
}
Comment
Answer by LeFlop2001 · Jun 19, 2020 at 05:56 PM
@fraubolat the error is somewhere else .this script activates and deactivates the weapons fine
Answer by Zoedingl · Jun 21, 2020 at 01:57 PM
You maybe forgot to assign values to the guns. It happens quite often.
Your answer
Follow this Question
Related Questions
ScreenPointToRay not responding 0 Answers
Dialogue System only plays the same words 1 Answer
Best way for sound and reload? 2 Answers
ui problem 0 Answers
I need help with dragging objects 1 Answer