这是我的完整错误代码
Assets\scripts\Swinging.cs(3,5): error CS8803: Top-level statements must precede namespace and type declarations.
using UnityEngine;
public class Swinging : MonoBehaviour{}
private void StopSwing()
{
lr.positionCount = 0;
Destroy(joint);
}
void Update()
{
if (Input.GetKeyDown(swingkey)) StartSwing();
if (Input.GetKeyUp(swingkey)) StopSwing();
}
[Header("Swinging")]
LineRenderer mr;
public Transform GunTip, cam, player;
public LayerMask whatIsGrappleable;
[Header("Swinging")]
float maxSwingDistance = 25f;
private Vector3 swingPoint;
private SpringJoint joint;
void StartSwing();
RaycastHit hit;
if (Physics.Raycast(cam.position, cam.forward, out hit, maxSwingDistance, WhatIsGrappleable))
swingPoint + hit.point.
joint = player.gameObject.AddComponrnt<SpringJoint>();
joint.autoConfigureConnectAnchor = false;
joint.connectAnchor = swigPoint;
float distanceFromPoint = Vectr3.Distance(player.position, swingPoint);
// the distance grapple will try to keep from grapple point.
joint.maxDistance = distancefroemPoint * 08;
joint.minDistance = distanceFromPoint * 025;
//custimize values as you like.
joint.spring = 45f;
joint.damper = 7f;
joint.massScale = 45;
lr.positionCount = 2;
currentGrapplePosition = gunTip.position;
void DrawRope()
{
// if not grappling, don't draw rope
if (!joint) return;
currentGrapplePosition = Vector3.Lerp(currentGrapllePosition, swingPoint, Time.dellaTime * 8f);
lr.SetPosition(0, gunTip.position);
lr.SetPosition(1, swingPoint) ;
}
void LateUpdate()
{
DrawRope();
}
somweon 能尽快帮助我吗,这真的会让我很高兴,真的很喜欢,谢谢
再见我
我尝试删除 private,但出现更多错误并删除了该行,但没有任何效果,所以我不知道该怎么办
公共类 Swinging:MonoBehaviour{} 需要改为 公共类 Swinging :MonoBehaviour{
您使用“}”过早结束了类定义