Search Unity

Moving objects to different positions with one animation

Discussion in 'Animation' started by matim11, Jul 23, 2017.

  1. matim11

    matim11

    Joined:
    Apr 3, 2016
    Posts:
    4
    Hello!

    How to make self-releasing playing cards at the very beginning of the game (so that when you start all the cards smoothly overlap each other)?
    Something like this
    upload_2017-7-23_10-26-4.png
    Code for the decomposition of cards:
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class SetCard : MonoBehaviour
    {

    [SerializeField]
    Card Card;
    Card AllCard;
    public float OffSetX = 0.5F;
    // Use this for initialization
    void Start()
    {
    Vector3 StartPosition = Card.transform.position;
    for (int s = 0; s <=32; s++)
    {
    AllCard = Instantiate(Card) as Card;
    AllCard.transform.position = new Vector3(StartPosition.x + (OffSetX*s), StartPosition.y,StartPosition.z);
    }
    }
    }

    I can not understand how to change the location for each copy of the object.
    OFFTOP.

    Is it possible to fit the size of sprites to the sample by the code? upload_2017-7-23_10-30-56.png