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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Short script help?

Discussion in 'Scripting' started by xXSilverswordXx, Nov 20, 2015.

  1. xXSilverswordXx

    xXSilverswordXx

    Joined:
    Nov 20, 2015
    Posts:
    7
    Currently working on a game for school,
    my idea is a first person flappy bird.

    One script i need help creating is the reset script.
    When the character collides with any object (terrain or obsticals) i want
    the scene to reset after a 2 second delay.

    We where using application.loadlevel(levelname)
    and it was not working

    Any help with this is appreciated :3
     
  2. tedthebug

    tedthebug

    Joined:
    May 6, 2015
    Posts:
    2,570
    Can you post your script (using code tags so it is formatted properly)
     
  3. xXSilverswordXx

    xXSilverswordXx

    Joined:
    Nov 20, 2015
    Posts:
    7
    here is the script so far
    p.s i dont know how waitforseconds works yet so any help on that is good
    ill attach a file since i dont know how code tags work and pastebin is blocked
     

    Attached Files:

  4. tedthebug

    tedthebug

    Joined:
    May 6, 2015
    Posts:
    2,570
    This script is on the pipes? The name of the level is spelt the same way with the same caps? You have added the level to the build settings?

    & to use code tags you press the icon that looks like a page (the 3rd one past the smiley face).
     
  5. xXSilverswordXx

    xXSilverswordXx

    Joined:
    Nov 20, 2015
    Posts:
    7
    the script is on the bird not pipes (does this change much?)
    what do you mean with the "build settings", currently its just testing in the actual game maker bit
    Level name is same with caps

    also how do i use waitforseconds
     
  6. tedthebug

    tedthebug

    Joined:
    May 6, 2015
    Posts:
    2,570
    I haven't used waitforseconds so can't help with that.

    It doesn't matter what object your script is on, I was just curious so I know which way round you are doing it. As you a doing fps I'm going to assume you are using 3D & not 2d. When using ontrigger one of the objects must have a rigidbody attached so I'd put it on your bird & set the birds collider as Trigger. For the call to load a scene to work it has to be assigned as a build scene so unity sort of knows about it (as you could end up with test scenes in your game that you don't want in the actual build). Details are on this link:

    http://docs.unity3d.com/ScriptReference/Application.LoadLevel.html


    Have you done the official unity tutorials via the learn link at the top of the page? They are the best place to begin, starting with the roll a ball one then working your way through to the more difficult ones.