Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Xyex Development · Jan 23, 2013 at 09:01 AM · interaction

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!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Berenger · Jan 23, 2013 at 09:18 AM

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 :)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Xyex Development · Jan 24, 2013 at 04:26 AM

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image NihkValentine · Mar 18, 2017 at 05:22 PM 0
Share

try looking on youtube. look for raycast and colliders. Learn and study about them. once you are comfortable, you can do it on your own.

I think you should stick to one of the scripting types. either C# or javasript. Probably C#.

avatar image
0

Answer by AnOrdinarySandwich · Mar 18, 2017 at 05:49 PM

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! :) 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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

12 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Help with loading new levels - restarting scripts 4 Answers

Find which scripts public variables appear in? 1 Answer

How to implement global AI and Activities? 0 Answers

NullReferenceException 1 Answer

How do you script movement and events(certain things happening when a button is pressed or an object is collided with) 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges