- Home /
Question by
bobbothedestroyer · Apr 17, 2018 at 03:57 PM ·
codepage
How do I change this `)' expecting identifier?
using UnityEngine;
public class gun : MonoBehaviour {
public float damage = 10f;
public float range = 100f;
public Camera fpsCam;
// Update is called once per frame
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);
Targett target = hit.transform.GetComponent<Targett>();
if (target != null)
{
target.TakeDamage(damage);
}
}
}
}
Comment
Best Answer
Answer by shadowpuppet · Apr 17, 2018 at 04:38 PM
Debug.log is just text, I believe, and needs quotations........ Debug.Log ("hello"); if you want to know what the raycast is hitting ,change that to ......print (hit.transform.name); Don't know if that solves your problem. It would help us to show the error code
Your answer
![](https://koobas.hobune.stream/wayback/20220612160949im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
change the source image in update function? help? 1 Answer
I have an attack/take damage script how do I make the player die when health hits 0? 1 Answer
GameObject SetActive Component not working After return message 3 Answers
I am having trouble assigning public gameObjects 3 Answers
Getting an object to re-spawn/ transform player back to the beginning 1 Answer