更新obi到7.1

This commit is contained in:
Bob.Song
2025-11-03 11:53:45 +08:00
parent d12e1bc495
commit 7cf7f545bc
1161 changed files with 158924 additions and 37802 deletions

View File

@@ -1,45 +1,53 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Obi;
[RequireComponent(typeof(ObiRope))]
public class CursorController : MonoBehaviour
namespace Obi.Samples
{
ObiRopeCursor cursor;
ObiRope rope;
public float minLength = 0.1f;
public float speed = 1;
// Use this for initialization
void Start ()
[RequireComponent(typeof(ObiRope))]
public class CursorController : MonoBehaviour
{
rope = GetComponent<ObiRope>();
cursor = GetComponent<ObiRopeCursor>();
}
// Update is called once per frame
void Update ()
{
if (Input.GetKey(KeyCode.W) && cursor != null)
public float minLength = 0.1f;
public float speed = 1;
private ObiRopeCursor cursor;
private ObiRope rope;
void OnEnable()
{
if (rope.restLength > minLength)
cursor.ChangeLength(rope.restLength - speed * Time.deltaTime);
}
rope = GetComponent<ObiRope>();
cursor = GetComponent<ObiRopeCursor>();
}
if (Input.GetKey(KeyCode.S) && cursor != null)
void Update()
{
cursor.ChangeLength(rope.restLength + speed * Time.deltaTime);
}
float change = 0;
if (Input.GetKey(KeyCode.A)){
rope.transform.Translate(Vector3.left * Time.deltaTime,Space.World);
}
if (Input.GetKey(KeyCode.W) && cursor != null)
{
change -= speed * Time.deltaTime;
}
if (Input.GetKey(KeyCode.D)){
rope.transform.Translate(Vector3.right * Time.deltaTime,Space.World);
}
if (Input.GetKey(KeyCode.S) && cursor != null)
{
change += speed * Time.deltaTime;
}
}
if (rope.restLength + change < minLength)
change = minLength - rope.restLength;
cursor.ChangeLength(change);
if (Input.GetKey(KeyCode.A))
{
rope.transform.Translate(Vector3.left * Time.deltaTime, Space.World);
}
if (Input.GetKey(KeyCode.D))
{
rope.transform.Translate(Vector3.right * Time.deltaTime, Space.World);
}
}
}
}