Please help

My unity is saying that there is a syntax error but I have look at my code over and over again and I can’t find what it means. here’s the code and here the errors Assets\Grapple.cs(63,30): error CS1003: Syntax error, ‘,’ expected and Assets\Grapple.cs(62,30): error CS1003: Syntax error, ‘,’ expected

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Grapple : MonoBehaviour
{
    private LineRenderer lr;
    private Vector3 grapplePoint;
    public LayerMask whatisGrappleable;
    public Transform gunTip, camera, player;
    private float maxDistance = 100f;
    private SpringJoint joint;

    void Awake()
    {
        lr = GetComponent<LineRenderer>();
    }

    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            StartGrapple();
        }

        else if (Input.GetMouseButtonUp(0))
        {
            StopGrapple();
        }

    }

    void LateUpdate()
    {
        DrawRope();
    }

    void StartGrapple()
    {
        RaycastHit hit;
        if (Physics.Raycast(camera.position, camera.forward, out hit, maxDistance))
        {
            grapplePoint = hit.point;
            joint = player.gameObject.AddComponent<SpringJoint>();
            joint.autoConfigureConnectedAnchor = false;
            joint.connectedAnchor = grapplePoint;

            float distanceFromPoint = Vector3.Distance(player.position, grapplePoint);


            joint.maxDistance = distanceFromPoint * 0.8f;
            joint.minDistance = distanceFromPoint * 0.25f;

            joint.spring = 4.5f;
            joint.damper = 7f;
            joint.massScale = 4.5f;
        }
    }

    void DrawRope()
    {
        lr.SetPosition(index 0, gunTip.position);
        lr.SetPosition(index 1, grapplePoint);
    }

    void StopGrapple()
    {

    }
}

https://docs.unity3d.com/ScriptReference/LineRenderer.SetPosition.html

LineRenderer.SetPosition only use 2 parameters
but you have 3
index, 0, gunTip.position

the error think you are missing “,” between index and 0

but the thing is you only need 0 no index

2 Likes

ok thanks for the help

1 Like

I will post it again for you:

How to understand compiler and other errors and even fix them yourself:

https://discussions.unity.com/t/824586/8

Look in the docs whenever you use a function you’ve never used before.

2 Likes