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 Kruga · Aug 01, 2010 at 10:07 AM · positionlightprimitives

Lights and Scripting and Positions

Why would this happen.. I place a light and a sphere in the same position. But when I compile the game. The light is offset from the sphere. As I approach the Light and Sphere. The Light seems to move around the sphere and move off to the other side. If they a supposed to be in the same position, why then dose the light move all over the place?? I placed a flare on the light to watch what it is doing...


using System; using System.Collections.Generic; using System.Text; using UnityEngine;

[RequireComponent(typeof(Light))] class SoloSystem :MonoBehaviour { public string SoloSystemName = "Unnamed"; public int SoloSystemID = 0; public SunType Suntype = SunType.Type_O; public List<Planet> Plants = new List<Planet>();

 void Start()
 {


     GameObject Sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
     Sphere.renderer.material.color = new Color(1.0f, 0.2f, 0.2f);
     Sphere.transform.position = transform.position;
     Sphere.transform.localScale = new Vector3(100.0f, 100.0f, 100.0f);
     Sphere.renderer.castShadows = false;
     Sphere.renderer.receiveShadows = false;
     Sphere.light.enabled = true; // If I enable it turns off the other light...?? why
     Sphere.light.range = (float)Suntype;
     Sphere.light.intensity = (float)Suntype;
     Label.target = Sphere.transform;

     light.intensity = (float)Suntype; //Enum basically = 30000:int
     light.range = (float)Suntype;
     light.transform.position = Sphere.transform.position; // Trying to work out
     light.transform.localScale = Sphere.transform.localScale; //trying to work out.
 }
 void Update()
 {

 }

}


I am new to this. So it might be something basic. I've only been playing around with it for 2 days...

Comment
Add comment · Show 1
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 Mike 3 · Aug 01, 2010 at 10:34 AM 0
Share

Not an error as such, but use transform.position ins$$anonymous$$d of light.transform.position - theres no point getting the light component just so you can get the transform component from it

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by AliAzin · Aug 01, 2010 at 10:29 AM

Try adding

Sphere.transform.position = transform.position;
light.transform.position = Sphere.transform.position; // Trying to work out
light.transform.localScale = Sphere.transform.localScale; //trying to work out.

to Update instead of Start method if your transforms are changing.

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

No one has followed this question yet.

Related Questions

lighting click help 3 Answers

light on collision help (scripting) 2 Answers

Shader errors 0 Answers

Positioning a GameObject so I't wont be inside another object 1 Answer

Weapon Possition Move On Sprint 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