Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 schwertfisch · Dec 17, 2010 at 09:35 AM · iosrotateshadowfollowplane

(iOS) Plane shadow that follows object on flat terrain - Translate but not Rotate.

I have a sphere that moves on a flat terrain by finger swipping. The sphere does not only translate but rotates too.

I was planning to use a plane at ground level with a shadow texture on it. Then parent my sphere to it. Then my "shadow" would follow my sphere like a real shadow (and I'd only be charged 1 draw call in comparison to using a blob shadow - that's my goal).

Of course my "shadow" rotates as my sphere rotates while translating.

I thought of using the same script that controls the sphere translation & rotation on the "shadow", after having removed the rotation-relevant lines of code. So the "shadow" would have a parallel behavior to the sphere, without the rotation.

Then I thought that maybe there is another way, less cpu demanding (supposing that using this 2nd script is a small extra burden for the cpu - and I am trying to avoid that as much as I can).

Any ideas on how to make the "shadow" follow the sphere without rotating, would be deeply appreciated. :-)

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

1 Reply

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

Answer by Eric5h5 · Dec 17, 2010 at 10:05 AM

Use a script on the shadow that just follows the sphere:

var transformToFollow : Transform; var offset = Vector3.zero; private var myTransform : Transform;

function Start () { myTransform = transform; }

function LateUpdate () { myTransform.position = transformToFollow.position + offset; }

Comment
Add comment · Show 3 · 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 schwertfisch · Dec 17, 2010 at 10:19 AM 0
Share

Thank you very much Eric5h5! That did it! In the meantime I also used the script that moves the sphere on the shadow (after removing the rotation-relevant lines of code) and it worked. It's a 100 line code basically (the sphere rotation is a bit sophisticated and I use some iTween classes hence the big length) and uses swipes as I mention in my Question. Using the code you nicely suggested, does the game become (at least a bit) "lighter" for the CPU or is the difference negligible and it doesn't make a difference CPU-wise? :-)

avatar image Eric5h5 · Dec 17, 2010 at 10:49 AM 0
Share

The script is nearly the $$anonymous$$imum possible CPU usage. You could potentially remove "offset" if you were using Vector3.zero for it anyway. I couldn't say what the difference is without seeing your script, but if you're getting input and applying it to the shadow, that's added CPU time right there. On mobile devices, it's important not just to consider the end result as frames per second, but also how much work you're making the CPU do, since everything you do drains battery, and you want to $$anonymous$$imize that as much as possible.

avatar image schwertfisch · Dec 17, 2010 at 12:10 PM 0
Share

Hmm I perfectly understand, thanks so much Eric5h5!

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

Camera rotation around player while following. 6 Answers

Enemy Pirate Ship AI 1 Answer

Follow object by Transform.Rotate 1 Answer

Dynamically Repeat plane to possible infinity 1 Answer

render only shadow on the plane, everything else to be transparent? 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