rabidus-test/Assets/Dreamteck/Splines/Examples/Projection/Scripts/AddForceAlongPath.cs

28 lines
632 B
C#
Raw Permalink Normal View History

2023-07-24 16:38:13 +03:00
namespace Dreamteck.Splines.Examples
{
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AddForceAlongPath : MonoBehaviour
{
public float force = 10f;
Rigidbody rb;
SplineProjector projector;
void Start()
{
rb = GetComponent<Rigidbody>();
projector = GetComponent<SplineProjector>();
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
rb.AddForce(projector.result.forward * force, ForceMode.Impulse);
}
}
}
}