Search Unity

Ball stuff

Discussion in 'Physics' started by Kemo458, Dec 28, 2015.

  1. Kemo458

    Kemo458

    Joined:
    Jun 26, 2015
    Posts:
    2
    Hello guys, im a complete new user of Unity.
    Reached lesson 7 from one youtube channel, but i came across a rather wierd problems with prefabs.
    Created a coin with few stuff in it, but cant duplicate it, in scene view it show in game view dissapears.
    If i put it in other "coin" it does wierd stuff and the main one has only rotation 360, not position... let me show you


    I even dont have an idea what is wrong... 2 questions:
    - How to duplicate the coin
    - How to make when ball touches the "main" coin, other coins not to disappear all.. obviously ball is "player" and coin is expecting "player", but want coins to disappear one by one when picked up.

    using this code on coins

    #pragma strict
    var coinEffect : Transform;
    function OnTriggerEnter (info : Collider)
    {

    if (info.tag == "Player")

    {
    var effect = Instantiate(coinEffect, transform.position, transform.rotation);
    Destroy (effect.gameObject, 3);
    Destroy(gameObject);
    Debug.Log("add coin counter here");
    }
    }

    Used unity just few hours... and having almost no codding skills, so please excuse me for the lame questions :)
     
  2. PGJ

    PGJ

    Joined:
    Jan 21, 2014
    Posts:
    899
    Have you tried disabling or removing the animations from your coin? I'm pretty sure that you have an animation that is rotating and that's the cause of your problems.
     
  3. PGJ

    PGJ

    Joined:
    Jan 21, 2014
    Posts:
    899
    Just realised that I perhaps was a bit vague as to why the second ball rotates in an orbit around the first. When you put the second coin as a child of the first and the first one has a animation that rotates it, then all children will rotate as well. Since the second coin is a bit further away, it will rotate in an orbit around its parent.