rb.velocity = ((transform.right * horizontal) + (transform.forward * vertical)) * speed;
var velocity = rb.velocity;
velocity......изменяешь скорость по осям, которые тебе нужны
rb.velocity = velocity; присваиваешь скорость
И то и то связано с тем что я эксперементирую и сам еще не решил что нужно использовать. Ну и конечно постоянные правки и переименования в которых тоже что то теряется.
Или все должно быть как в примере с помощью функции Get() и функции Set()?
public class Document
{
public string Text { get; set; }
}
public class Human
{
public void ReadDocument(Document document)
{
Debug.Log(document.Text);
}
}
public class Document
{
private readonly string _text;
public Document(string text)
{
_text = text;
}
public void Print()
{
Debug.Log(_text);
}
}
public class Human
{
public void ReadDocument(Document document)
{
document.Print();
}
}
using BehaviorDesigner.Runtime.Tasks;
using UnityEngine;
namespace BehaviourTree.Brain
{
public class LocateTarget : Action
{
public float Fov;
public float CheckRadius;
public LayerMask TargetMask;
public Bot Bot;
public SharedTarget Target;
public override TaskStatus OnUpdate()
{
var foundTarget = FindTarget(CheckRadius, TargetMask);
if (foundTarget == null) return TaskStatus.Failure;
var eye = new Eye(Fov, Bot.transform);
if (eye.InSight(foundTarget) == false) return TaskStatus.Failure;
Target.Value = foundTarget;
return TaskStatus.Success;
}
private SomeTarget FindTarget(float radius, LayerMask mask)
{
var results = new Collider[64];
SomeTarget target = null;
if (Physics.OverlapSphereNonAlloc(Bot.transform.position, radius, results, mask) == 0) return target;
foreach (var collider in results)
{
if (collider == null) break;
if (collider.TryGetComponent(out SomeTarget found) == false) continue;
target = found;
break;
}
return target;
}
}
}
Да и спотыкаться лучше ему самому
и улучшать код