2024-11-12 17:59:34 +01:00

26 lines
684 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BouncingArrow : MonoBehaviour
{
public float bounceHeight = 0.25f; // Height of the bounce
public float bounceSpeed = 4f; // Speed of the bounce
private Vector3 originalPosition;
void Start()
{
originalPosition = transform.position;
}
// Update is called once per frame
void Update()
{
// Calculate the new position with a bouncing effect
float newY = originalPosition.y + Mathf.Sin(Time.time * bounceSpeed) * bounceHeight;
transform.position = new Vector3(originalPosition.x, newY, originalPosition.z);
}
}