So I'm trying to calculate an object's future position so my enemy can land to it safely. Idea is that using the future position I can calculate the angle and convert it to a direction vector and also using distance I can calculate the speed necessary to reach its target. I'm still kind of stuck with this idea.
Here is code which I'm using at the moment.
// Find the close platform to land
Transform _tmp = GetClosestPlatform(SpawnerNew.Platforms);
// Hard coded time, should be time which enemy should take to reach position
float _constNeededTime = 3f;
// As my game's speed always increasing every frame so I need to calculate it also how it's in future (GameManager.Instance.OverAllSpeedModifier is called 10x times / sec)
float _anticipatedLevelSpeed = GameManager.Instance.CurrentLevelSpeed + (GameManager.Instance.OverAllSpeedModifier * _constNeededTime * 10);
// trying to calculate the future postion of the platform
Vector3 _anticipatedLoc = _tmp.transform.position - new Vector3((_platformSpeed * _anticipatedLevelSpeed) + _constNeededTime, 0f, 0f);
// Calculate angle
float _angle = Mathf.Atan2(transform.position.y - _anticipatedLoc.y, transform.position.x - _anticipatedLoc.x) * 180 / Mathf.PI;
// Convert angle to vector direction
_nearestPlatformDir = new Vector3(Mathf.Cos(_angle * Mathf.PI / 180f), Mathf.Sin(_angle * Mathf.PI / 180f), 0);
// Trying to calculate speed needed to reach platform
_neededSpeed = Vector3.Distance(_anticipatedLoc, transform.position) / _constNeededTime;