Transition Free Fall into Sinus Hovering

I have a character that should hover above a platform with a nice sinus based up and down movement.

Now the character jumps to this platform from above. I dont know from which height he jumps, so the his fall speed is variable. How would I compute that transition without my character touching the platform?

I’m thinking about this for a long time now, some help would make my day! :slight_smile:

You can’t store the last hover height before the jump and include that into the jump arc calculation?

In that case here’s a more complete answer:

using System.Collections.Generic;
using UnityEngine;

public class Jumper : MonoBehaviour
{
	public float m_upwardsMomentum = 200;
	public float m_forwardMomentum = 100;
	public Transform m_target;
	public bool m_doJump;
	public float m_gravity = 9.8f;
	public float m_terminalVelocityTime = 1.0f;
	public float m_minUpdate = 0.033333f;
	float m_lastUpdate;
	float m_fallSeconds;
	bool m_jumping;
	List<Vector3> m_trail;
	
	void UpdateJump()
	{
		float deltaTime = Time.time - m_lastUpdate;
		if(deltaTime <= m_minUpdate)
			return;
		
		
		
		m_lastUpdate = Time.time;
		if(m_trail == null)
			m_trail = new List<Vector3>();
		m_fallSeconds += deltaTime;
		
		Vector3 curPos = transform.position;
		Vector3 tarPos = m_target.position;
		float curHeight = curPos.y;
		
		
		float newHeight = curHeight;
		newHeight += m_upwardsMomentum * deltaTime;
		newHeight -= m_gravity * Mathf.Min(m_terminalVelocityTime, m_fallSeconds);
		
		if(newHeight <= tarPos.y - 0.01f)
		{
			m_jumping = false;
			newHeight = tarPos.y;
		}
		
		float newForward = curPos.x + (m_forwardMomentum * deltaTime);
		
		
		
		Vector3 newPos = curPos;
		newPos.y = newHeight;
		newPos.x = newForward;
		transform.position = newPos;
		
		m_trail.Add(newPos);
		
	}
	
	void Update()
	{
		if(m_doJump)
		{
			m_jumping = true;
			m_doJump = false;
			m_lastUpdate = Time.time - m_minUpdate;
		}
		
		if(m_jumping)
			UpdateJump();
		
		Color startTrail = Color.green;
		Color endTrail = Color.red;
		if(m_trail != null)
		{
			for (int i = 0; i < m_trail.Count - 1; i++)
			{
				Color thisColor = Color.Lerp(startTrail, endTrail, (float)i/(float)m_trail.Count);
				Debug.DrawLine(m_trail*, m_trail[i + 1], thisColor);*
  •  	}*
    
  •  }*
    
  • }*

}

Thanks for the answer above. Its not exactely the solution to my problem, but helpful!
Maybe an image can explain a bit better what I’m looking for:
alt text
The jump is no problem, the sinus floating is no problem, but how do I combine it? How do I do a transition from the jump to the sinus and vice versa?

Any ideas? Thanks for the answers so far!