这是我的脚本
我的问题 Assets\scripts\Swinging.cs(2,1):错误 CS0106:修饰符“private”对此项目无效
using UnityEngine;
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();
}
我试图删除修改器私人半身像,但我遇到了更多问题 这很难解决,我需要一些帮助 请帮助我
首先要有一个“;”在你的 stopSwing() 方法结束时,这似乎很不寻常。 其次,你不能在什么都没有的情况下声明私有函数。我的意思是你需要把它放在课堂上。示例:
public class Swinging :MonoBehaviour {
private void StopSwing()
{
lr.positionCount = 0;
Destroy(joint);
}
void Update()
{
if (Input.GetKeyDown(swingkey))
StartSwing();
if (Input.GetKeyUp(swingkey))
StopSwing();
}
// rest of the code below
}