Coder Social home page Coder Social logo

redirecting-the-scene's Introduction

Redirecting-the-scene

Aim:

To Redirect the scene in the unity engine.

Algorithm:

Step 1 :

Create a new 3D scene in the unity and save it as Level1.

Step 2 :

From the Hierarchy , select a plane , cube and a sphere and place in the scene. Scale of plane is (4,1,4) .Scale of Cube is (2,1,2).Scale of sphere is (1,1,1).

Step 3 :

Right Click on Assets , choose material and give color to your cube and sphere.

Step 4 :

Add rigid body component to cube and sphere.

Step 5 :

Select the sphere, in the inspector - select tag and add a new tag named "cube".And tag the cube in sphere inspector.

Step 6 :

From File , create another scene and name that scene as "Level2".

Step 7 :

Create a C# file named Prog and type the code required to redirecting the scene. And Add the C# file to the cube.

Step 8 :

From File, select Build settings and add open scene.Both the scene should be added.

Step 9 :

From Hierarchy , Select text and type " YOU WON ", and uncheck the text in inspector.

Step 10 :

Slect the cube inspector , add the text object in the WinText feild under the C# file.

Step 11 :

Compile and run the program, as a result when the sphere falls on the cube ,it gets disappeared and the text message will pop up on the scene . On clicking "R",the level1 scene will be redirected to Level2 scene.

Program:

Developed By : Sowmiya N
Register No : 212221230106

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class Prog : MonoBehaviour
{
    Rigidbody rb;
    public GameObject WinText;
    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent<Rigidbody>();
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.R))
        {
            SceneManager.LoadScene("Level2");
        }
    }
    public void OnMouseDown()
    {
        Destroy(gameObject);
    }
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "cube")
        {
            Destroy(collision.gameObject);
            WinText.SetActive(true);
        }
    }
}

Output:

op op op op

Result:

Thus redirecting a scene is done successfully in the unity engine.

redirecting-the-scene's People

Contributors

archanasharikalharinarayanan avatar sowmiya2003 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.