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 LesPaul · May 07, 2013 at 10:05 AM · inspectorlerpaxis

Define lerp axis through inspector

Hey guys,

Is it possible to define an axis for an object to lerp on in the inspector?

Comment
Add comment · Show 4
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 MrVerdoux · May 07, 2013 at 10:22 AM 0
Share

Can you explain yourself better? I might know the answer but I'm not quite sure what you want to achieve.

avatar image LesPaul · May 07, 2013 at 10:25 AM 0
Share

What i want to achieve is the following.

I have a script that animates gun parts. This script van be used for multiple guns, but the part of the different guns don't always have the same orientation for the xyz axis. Through the inspector i want to be able to define on which axis they have to lerp.

avatar image MrVerdoux · May 07, 2013 at 10:35 AM 0
Share

But a lerp in a 3D flat space has only one possible way to be done. From point A to point B the only possible path is the line from A to B. Do you mean you want to move only in one plane, even if that doesn't bring you from A to B?

For example: A = (0,0,0); B = (0,1,1);

You want to lerp en the xy plane so in the end: A = (0,1,0);

is this right?

avatar image LesPaul · May 07, 2013 at 12:07 PM 0
Share

The thing i do is this for one specific axis: slide.transform.localPosition.z = $$anonymous$$athf.Lerp(slide.transform.localPosition.z,-0.1,Time.deltaTime*10);

The thing i want is that i somehow dont need the localPosition.z anymore. Just one var or something

1 Reply

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

Answer by MrVerdoux · May 07, 2013 at 12:25 PM

Wow it looks to me that you are overthinking this, but maybe I'm wrong, let's see.

Why don't you use the lerp from Vector3 class? It may suit your purpouses better.

Otherwise, I think you are trying just to move a thing smoothly. Why don't you move it normally but you make the velocity itself to be lerped.

Another option is to make a class that can be set through the inspector and does this:

 [System.SerializableAttribute]
 public class Axis{

    public enum AxisStateMachine{
    Xaxis,
    Yaxis,
    Zaxis,
    }
 
    public AxisStateMachine axis;
 }

Then you would be able to use this class in your weapon and make a more complex function that would take into acount the information of the axis to do as you want, and you would be able to set the axis through the inspector.

Hope it helps.

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

13 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 avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Enemy prefab's script won't keep inspector-applied settings. 0 Answers

Mathf.Lerp not working as expected 2 Answers

Lerping back and forth like a swipe page effect 0 Answers

Can I limit the rotation of an Object on an axis between a Negative and Positive value? 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