Hello , this is Mahsa
I wanna pickup some objects , for example some (logs) , and I want them to be like this →
I have two list : list number 1 and list number two, when I pickup the log number 1 I want to go to the list number 1, then when I pickup log number 2 I want to go in list number 2, and collecting logs happening in a IEnumerator.
private IEnumerator MoveLogToLogStack(ResourcesData log)
{
WaitForEndOfFrame wait = new WaitForEndOfFrame();
float timer = 0;
float duration = 0.3f;
var lastTileLocalPos = Vector3.zero;
if(inputLogList_1.Count > 0)
{
lastTileLocalPos = inputLogList_1.Last().stackLocalPosition;
}
log.stackLocalPosition = lastTileLocalPos + Vector3.up * log.logHeight;
log.transform.parent = logStackPoint_1;
var startPos = log.transform.localPosition;
log.CanCollect = false;
inputLogList_1.Add(log);
while(timer < duration)
{
timer = Mathf.Min(timer + Time.deltaTime, duration);
float t = timer / duration;
var targetPos = lastTileLocalPos;
var position = Vector3.Lerp(startPos, targetPos, t);
position.y += animationCurve.Evaluate(t);
log.transform.localPosition = position;
yield return wait;
}
}
This just goes in the first list