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 TheRichardGamer · Jun 27, 2013 at 10:50 AM · error

How to make a smooth transition between Vector3's

Hi, so I am trying to do a smooth transition between two positions whenever a controller isGrounded or not. But it doesn't seem to work. Can anyone help me with this please?

Here's my script:

 var DefaultPose : Vector3;
 var AirPose : Vector3;
 private var CurrentPose : Vector3;
 var PlayerCon : CharacterController;
 var Smooth : float = Time.deltaTime * 3;
 
 function Update () {
 
  if(PlayerCon.isGrounded == false){
 
        transform.localPosition = AirPose * Smooth;
 
 
   }
   
   else
   
   if(PlayerCon.isGrounded == true){
 
        transform.localPosition = DefaultPose * Smooth;
 
 
   }
 
 
 }
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 clunk47 · Jun 27, 2013 at 03:34 PM 0
Share

Have a look at Vector3.$$anonymous$$oveTowards, and try using smoothDeltaTime along with it.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by mohitramani · Jun 27, 2013 at 10:59 AM

You could use either of the following: Vector3.Lerp(Vector3 from, Vector3 to, float time); Vector3.SLerp(Vector3 from, Vector3 to, float time); SmoothDamp (Vector3 current,Vector3 target, ref Vector3 currentVelocity, float smoothTime, float smoothTime);

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

Answer by rogeliopuig · Jun 27, 2013 at 10:57 AM

I'm not sure what you are trying to achieve but I wouldn't do it in the update Loop anyway, here's an approach.

 float _smoothValue;
 if (PlayerCon.isGrounded) {
     transform.localPosition =  Vector3.Lerp(transform.localPoistion, Airpose, _smoothValue);
 }
 else {
     transform.localPosition =  Vector3.Lerp(transform.localPoistion, DefaultPose, _smoothValue);
 }
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 TheRichardGamer · Jun 27, 2013 at 11:06 AM 0
Share

should I put Smooth * Time.deltaTime or what?

avatar image rogeliopuig · Jun 27, 2013 at 11:14 AM 0
Share

Time.deltaTime changes at every frame and you are initializing it at the very beggining. Not if you are using Lerp cause lerp interpolates between 0 and 1. If you give us more information on what you are trying to achieve we could help you more. Thumbs up if it helps!

avatar image TheRichardGamer · Jun 27, 2013 at 11:22 AM 0
Share

Well, I am trying to make a parkour system, kinda, and I want my arms to have a smooth transition to the position they're gonna be in when you're in the air or when you're on the ground and they will lower. That's what I'm trying to achieve.

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

18 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 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

Opening Script Problem 1 Answer

Weird collision error when using waypoint script... 1 Answer

Animation spins wildly after completed 0 Answers

Getting index of the smallest number in a list 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