Question by
Commander-Rabbit · Jun 22, 2016 at 09:27 PM ·
scriptingproblem
the debug.Log isnt showing up in my console
I'm trying to shoot at the ground and have it pop up in the console so I can know I can shoot but its not working is it something with input manager. Heres the code I'm using. public PlayerWeapon weapon;
[SerializeField]
private Camera cam;
[SerializeField]
private LayerMask mask;
void start()
{
if (cam == null)
{
Debug.LogError("PlayerShoot: No camera referenced!");
this.enabled = false;
}
}
void update()
{
if (Input.GetButtonDown("Fire1"))
{
Shoot();
}
}
void Shoot()
{
RaycastHit _hit;
if (Physics.Raycast(cam.transform.position, cam.transform.forward, out _hit, weapon.range, mask))
{
Debug.Log("We hit" + _hit.collider.name);
}
}
Comment
Answer by gjf · Jun 22, 2016 at 05:27 PM
are you expecting unity to call start()
& update()
? it won't!
try Start()
& Update()
;)
pay special attention to using the correct case when using built-in methods/properties/etc.
Your answer
![](https://koobas.hobune.stream/wayback/20220612083447im_/https://answers.unity.com/themes/thub/images/avi.jpg)