Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Spawning going wrong.

Discussion in 'Scripting' started by tomowale, Mar 19, 2015.

  1. tomowale

    tomowale

    Joined:
    Feb 14, 2015
    Posts:
    308
    When I spawn my cube it works but they go away from the player and spawn croooked any way to fix this?
     
  2. Roderyk

    Roderyk

    Joined:
    Mar 5, 2015
    Posts:
    75
    Code?
    Screenshot?
    Better description of the problem?
     
  3. proandrius

    proandrius

    Unity Technologies

    Joined:
    Dec 4, 2012
    Posts:
    544
    Just define rotation yourself.
     
  4. tomowale

    tomowale

    Joined:
    Feb 14, 2015
    Posts:
    308
    Code
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class CreateCube : MonoBehaviour {
    5.     public GameObject Car;
    6.  
    7.     // Use this for initialization
    8.     void Start () {
    9.         StartCoroutine (EnemySpawn ());
    10.     }
    11.    
    12.     IEnumerator EnemySpawn()
    13.     {
    14.         while (true)
    15.         {
    16.             Instantiate (Car, transform.position,Quaternion.identity);
    17.             yield return new WaitForSeconds(3);
    18.         }
    19. }
    20. }
     

    Attached Files:

  5. TRG96

    TRG96

    Joined:
    Mar 26, 2011
    Posts:
    102
    Does the transform and the cube have collides or rigidbodies? the collides are probably colliding thats why they are appearing crooked and moving around. try spawing the cube a bit away from the transform or delte the collider from the transform.
     
  6. tomowale

    tomowale

    Joined:
    Feb 14, 2015
    Posts:
    308
    I am spawning the cubes on empty game objects so they dont have colliders . The player and car have colliders if thats what you mean.
     
  7. Roderyk

    Roderyk

    Joined:
    Mar 5, 2015
    Posts:
    75
    Who is using the CreateCube script? An empty gameObject? The Player? The Car?
    If it's an empty gameObject, is the position the same as the player/car?
     
  8. tomowale

    tomowale

    Joined:
    Feb 14, 2015
    Posts:
    308
    Listen guys I am sure this has happened to many beginners but I screwed up and now I cant see the terrain or anything . It is still normal in the game view but how do I get back to perspective view. Sigh
     

    Attached Files:

  9. Roderyk

    Roderyk

    Joined:
    Mar 5, 2015
    Posts:
    75
    I think you need to check some tutorials before diving in the programming.
    Try selecting an item for the hierarchy, move your mouse over the scene view and press F. With Alt + LeftMouse you rotate. Also, use the gizmo in the upper right of the scene view to change viewpoints.
     
  10. tomowale

    tomowale

    Joined:
    Feb 14, 2015
    Posts:
    308
    I have , it's kinda sad I come off that way to some of you , that I know nothing , but I do , I just ask for help when I am stuck. I saw that F fix 100 times doesn't really work, but I did manage to get above the objects view. DO you know how to get down to the objects perspective now?
    P.S it seems you think I don't know about the gizmo , I do as like I said I have watched too many tutorials already, its just that once you click the gizmo and it goes to a next view you cannot get it back to perspective view.
     

    Attached Files:

  11. tomowale

    tomowale

    Joined:
    Feb 14, 2015
    Posts:
    308
    Oh btw the empty game objects I spawn the cubes on is using the createcube script. Lol I tried placing the emptyobjects at the exact position as the player , good test but i want them coming at the player from the direction its facing.
     
  12. tomowale

    tomowale

    Joined:
    Feb 14, 2015
    Posts:
    308
    At this point I think I may restart building my game , but this time just download assets and start building my REAL game instead of a prototype. What do you think?just need to save my scripts though.

    You know how it is being a frustrated programmer.
     
  13. Roderyk

    Roderyk

    Joined:
    Mar 5, 2015
    Posts:
    75
    I work as a programmer, and my first steps with unity is building prototypes. All with primitives 3d forms. And make scripts for movement and behavior.
    Recycling will help you learn, but (as i think) don't worry about making your first game if you cannot manage the environment and scripting too well (as I do. I just try try try try things. Let the importing of assets to the future, when you know what you are doing :p)
     
  14. tomowale

    tomowale

    Joined:
    Feb 14, 2015
    Posts:
    308
    OK man you helped a lot , I will take the advice and just keep trying as you said. Despite this though is there anything I can do to the scene view to get it back to default or am i screwed ?:oops::rolleyes:o_O
     
  15. Roderyk

    Roderyk

    Joined:
    Mar 5, 2015
    Posts:
    75
    It never happend to me, nor i know if there's a hotkey to put the scene view as you did. With Alt+Mouse you cant rotate the view?
     
  16. tomowale

    tomowale

    Joined:
    Feb 14, 2015
    Posts:
    308
    Basically I managed to defy the laws of F up , and mess up my scene view to the pint of where I don't know where anything is basically I want my scene view to be right by the perrspictive of the objects.S o much to the point I cant see the spawn objects anymore. SO as i said I may have to restart my project.
     
  17. tomowale

    tomowale

    Joined:
    Feb 14, 2015
    Posts:
    308
    Lol after I finish getting errors and what not out the way its gonna be a pretty big transition to a car game lol.
     
  18. tomowale

    tomowale

    Joined:
    Feb 14, 2015
    Posts:
    308
    Oh by the way Thanks man , because of you I snapped back into sense and said I am not giving up.:)