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 u3dclt · Mar 29, 2011 at 01:18 PM · instantiateprefabpositionlerp

Lerp to position in instantiated prefab?

Hey guys,

I'm wondering if it's possible to Lerp to a target position in an instantiated prefab. Maybe with a target that has an appropriate tag? Not sure. The target position would be on a particular axis. X or Y.

I'm new to Lerp so I'm trying to feel my way around.

Thanks in advance for any and all help!

Comment
Add comment · Show 2
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 Owen-Reynolds · Mar 29, 2011 at 03:40 PM 0
Share

Lerp is just a weighted average: Lerp(a,b,0.5) makes a number 1/2 way from a to b. The exact same thing as (a+b)/2. Best to start by thinking if you want to move smoothly, move using "physics" speed-up, etc... . Once you know what you want to get, look for solutions.

avatar image u3dclt · Mar 29, 2011 at 05:18 PM 0
Share

Owen, Thanks for the info! I need to check into that also. Speed, physics, etc. I know I ran across this before something that would be the equivalent to applying a function curve. Like ease in/out. Can't remember where I saw that.

1 Reply

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

Answer by Justin Warner · Mar 29, 2011 at 02:05 PM

http://unity3d.com/support/documentation/ScriptReference/Vector3.Lerp.html

Example code shows how to make an object move somewhere (Hint, read the green text).

http://unity3d.com/support/documentation/ScriptReference/index.Accessing_Other_Game_Objects.html

Look for number 3.

This should help. Reason for this is so you can look around the API and get a feel on how to use it, as that's how you'll learn most of your scripting...

So... get target object, put that in a spot on the lerp, then get the actual target, put that on the other lerp, then add in the time to do it... now I don't know how you want this to start... But I'll assume it is when it's instantiated... So, put that in an function Awake(), on to the actual target, and then you don't really need the second link, as you can do this.gameObject, and then the other object to move to it is already there... So just make that a var...

But hope this helps =).

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 u3dclt · Mar 29, 2011 at 05:14 PM 0
Share

Thanks for the info, Justin! I appreciate it. I'll have to mess around with that a bit so much capability in Unity!

In the end, I might end up Lerping on a grid. Just looking for the best solution. The player-movement grid will be active over a tiled-texture (grid) background. I guess the grid would be the most accurate overall, being that the player can continue on in the scene for an unlimited distance.

Still have a lot of research to do.

avatar image Justin Warner · Mar 29, 2011 at 09:19 PM 0
Share

Yes, Unity is vast, however, the problem, which you seem to overcome, is actually asking the RIGHT question, but mostly, RESEARCH, which contributes to questions, and actually understanding answers... But yes, as long as you look around, and put forth effort, anyone can help you =).

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

Help making a damage number system 1 Answer

How to instantiate in self position. 1 Answer

Instantiate a prefab at the Mouse's position? 1 Answer

problem whit Instantiate Prefabs position. 0 Answers

How to instantly move a newly instantiated prefab? 2 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