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 Hydraxia · Aug 05, 2012 at 12:08 PM · camerascreenframehealth

Some questions by noobie me

Hello!

I have some problems,i beginned only few days ago.

So i attached a Flashlight to my character,and an Light ''effect/lamp''. It works perfectly,but i want to switch it on/off. I'm in trouble. I dont know where to start/create a new script,than where to place it. In script,i don't know how to point to an direct object. I want the script only for the ''FlashlightLight''. When i press F,the Light activates,turns on.When i press F again,it turns off/the light will be inactive. Anyone can help?

Here is the 2nd problem :/ When i find answer to first,this will be probably easy. I want to hold Shift,and while Shift is holded down,increase the speed of my character.

The third: Can i attach images directly to the characters camera/screen? I made an frame in GIMP for the health bar. How can i make it?

Thank you guys/girls!

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

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by ScroodgeM · Aug 05, 2012 at 12:14 PM

answer 1

LghtSwitcher.cs

using UnityEngine;
using System.Collections;
public class LightSwitcher : MonoBehaviour
{
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.F))
        {
            light.enabled = !light.enabled;
        }
    }
}

save it to assets folder anywhere and then attach (drag-n-drop) to the light object in scene

answer2

just add to character's control script interaction with Input.GetKey(KeyCode.LeftShift)) to modify speed similar to previous script

answer 3

check Unity GUI mechanism

http://docs.unity3d.com/Documentation/Components/gui-Basics.html

it's very basics but enough to understand how it works.

Comment
Add comment · Show 2 · 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 Hydraxia · Aug 05, 2012 at 01:00 PM 0
Share

But how can i make an GUI with texture? i want an frame,i made/draw in GI$$anonymous$$P,in the corner

avatar image ScroodgeM · Aug 05, 2012 at 01:06 PM 0
Share

choose what you find better for your task:

http://docs.unity3d.com/Documentation/Components/class-GUIStyle.html

http://docs.unity3d.com/Documentation/ScriptReference/GUI.DrawTexture.html

http://docs.unity3d.com/Documentation/Components/class-GuiTexture.html

avatar image
0

Answer by Hydraxia · Aug 05, 2012 at 01:54 PM

The 3. is very useful.

But i dont understand the first. (i understand,but doesn't work) The light is automatically turned on,so i can't swith it up,or down,because 1. its turned on 2. i dont know how to turn off/down

And at answer2,i dont know how to change the speed,don't know how,or what script to use :/

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 ScroodgeM · Aug 05, 2012 at 01:58 PM 0
Share

1

light.enabled = !light.enabled;
this line inverts current light state, so it switches it on if it off and switch off is it on.

2

this depends on what move controller you use, you should know from this controller where it stores a speed or how it can be configured.
avatar image
0

Answer by Hydraxia · Aug 05, 2012 at 04:51 PM

This light doesn't work. Or just i'm idiot.

I have Character,and there the Camera and the Flashlight (It doesn't have model yet)

I made this script,and put in the Flashlight. Right?

I start game,the flashlight is automatically turned on,but i press F,nothing happens :/

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 ScroodgeM · Aug 05, 2012 at 05:53 PM 0
Share

your flashlight - what exactly is this? this script is for any light in Unity, light that illu$$anonymous$$ates light and make all things aroung affect by light. this light is turned on/off by this script.

  • in unity hierarchy select Create - Direction light, scene should be affected by this light

  • drag-n-drop my script to this light

  • run game

  • press f, light should be switchen on/off.

if you 'flash light' is something another, not the one of unity light, then i understand you wrong.

avatar image
0

Answer by reptilebeats · Aug 05, 2012 at 06:12 PM

seeing as you are new i would a advise you to look for will goldstone on youtube and follow all his tutorials step by step, they will take you a couple days to complete depending on how many times you repeat them.

this is what i followed when i first started with no previous experience in anything except from music and they helped a lot, i also saved all the scripts as a reference which have now been deleted as its all in memory now and i understand it better

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

9 People are following this question.

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

Related Questions

how to have an object positioned relative to the screen(like a button) 1 Answer

UI render doesn't sync with Camera movement 2 Answers

Finding the faces of a collider box and framing them in camera 0 Answers

Camera zoom while keeping an off-center object at the same screen co-ordinates 1 Answer

How to apply screen wrapping fit for any resolution? 0 Answers


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