Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Issue with attempting to use a raycast

Discussion in 'Scripting' started by crispysnore, Jul 6, 2022.

  1. crispysnore

    crispysnore

    Joined:
    Aug 2, 2016
    Posts:
    5
    As title says above, I'm attempting to make a raycast so that I can detect objects with it.

    I've tried following this tutorial:


    I've copied the code 1:1 but unity is throwing some errors. I've also noticed that some text should be coloured and isn't for some reason.
    The errors are as follows:
    Assets/Scripts/RPGPlayer.cs(42,54): error CS1525: Unexpected symbol `hit'
    Assets/Scripts/RPGPlayer.cs(48,16): error CS1519: Unexpected symbol `else' in class, struct, or interface member declaration
    Assets/Scripts/RPGPlayer.cs(48,40): error CS1519: Unexpected symbol `==' in class, struct, or interface member declaration
    Assets/Scripts/RPGPlayer.cs(50,43): error CS1519: Unexpected symbol `It's the ENEMY!!!!!' in class, struct, or interface member declaration
    Assets/Scripts/RPGPlayer.cs(52,9): error CS8025: Parsing error
     
  2. crispysnore

    crispysnore

    Joined:
    Aug 2, 2016
    Posts:
    5
    Nevermind I found another tutorial that works. Don't know what caused those errors though.
    This is the tutorial for anyone who might need a working one.
     
  3. FlashMuller

    FlashMuller

    Joined:
    Sep 25, 2013
    Posts:
    449
    As we can't see the code it's hard to tell exactly, but it sounds like you are missing a } somewhere.