Scripting/Animation Help?

Okay, essentially, I need to design a game to incorporate 25 questions. What I wanted to do is have the player interact with the door, and then when the player interacts, it would have dialogue box of some kind pop up and present the question and answer choices. Then if the question is answered correctly the door will open. Could I possibly get suggestions as to what to do. And keep it simple as possible please. I am very new, and am kind of being forced to jump right into this stuff, as it is a school project. Thanks so much everyone!

Interaction : When an input occurs (let’s say space was pressed), cast a ray forward to check if the player is looking at the door, and if it is close enough. The door needs a collider (not trigger, or you’ll walk through). If those conditions check out, next point.

Question : you have the display part (the question in GUI), and the input part, where you wait for the player to answer. Might be a button, or a text field, or a toggle field etc. Anyway, check if the answer given is the one expected, and if it is, next !

Door opening : You need an animation on that door. You can do it in Unity or in your modelling app. Don’t forget to put your pivot on the hinges, or it won’t open properly. Set the door animation’s name to “opening”.
Back to the code, when the player answered correctly :

door.animation.Play("opening");

Good luck :slight_smile:

The problem is I need help doing most of that. I am completely new :/. Not very fluent in javascript or C# coding. Which I know making a game and not being good with this is generally not good. But I kind of have to jump into this. I could figure out the animating, I just need help making a ray cast and and GUI with the questions.

Here’s the raycasting code example from Unity5’s raycasting documentation page

using UnityEngine;

public class ExampleClass : MonoBehaviour 
{
    void FixedUpdate() 
    {
        Vector3 fwd = transform.TransformDirection(Vector3.forward);

        if (Physics.Raycast(transform.position, fwd, 10)) 
            print("There is something in front of the object!");
    }
}

As for the GUI, I suggest playing with Unity’s GUI stuff - the best way to learn is to do! :slight_smile: Create a canvas first, as this is where all gui parts will go. Try adding and playing around with the UI elements and see what you can accomplish, and then come back here for more help if you need it. Here’s the link for Unity5’s UI documentation, too.