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 jbalzer · Mar 03, 2011 at 10:35 PM · slerpeasing

Slerp and Easing: Attempting to fire a projectile along an arc

I want a character to launch a missile at a foe, and I'm using a small missile mesh to get from one to the other. Now, if the character isn't facing the foe directly, I want the missile to fire out straight away from the character a bit before arcing toward the foe.

My original thought was to have a waypoint in between, so that the missile first moves via Lerp or MoveTowards until it reaches the waypoint, then via Slerp to the foe. However, the result is that once the missile reaches the waypoint, it turns sharply and moves in a slight arc from then on. It looks like it bounced off an invisible wall.

I've looked for some kind of simple-to-use easing function to bridge that waypoint, but I'm not finding much. I'm hoping there's a simpler way to do this then spelling out a bunch of math for how to handle the waypoint transition.

Currently, my Slerp command looks like this:

transform.position = Vector3.Slerp(transform.position,target.transform.position,mySpeed/distance * .025);

Any ideas on how to make something like this work?

Thanks in advance!

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by jbalzer · Mar 03, 2011 at 11:22 PM

Well, I think I came up with something that seems to work ok. The following is called via the FixedUpdate:

angleAmount : float = 0.01; // this is actually set whenever the shootWaypoint is reached
if (shootWaypointReached) {
    var direction:Vector3 =  target.transform.position - transform.position;
    var targetRotation = Quaternion.LookRotation(direction);
    var angleDifference = Quaternion.Angle(transform.rotation, targetRotation);
    if (angleDifference > 0){ 
        angleAmount = Mathf.Lerp(angleAmount,.5,.005);
        fireObject.transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, angleAmount);
    }
    transform.position += (transform.forward * speed);
} 

However, I'm open to any wiser advice than this.

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 Patyrn · Mar 04, 2011 at 12:05 AM

Might be worth trying this out:

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

I haven't actually used this method before, but it's what I was planning on starting with when I write a guided missile.

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 tool55 · Mar 04, 2011 at 01:31 AM

I posted this answer for another similar question. Perhaps it will help you:

http://answers.unity3d.com/questions/42653/how-to-control-the-speed-of-look-at/42704#42704

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

Rotation Ease-In-Out with MAX Rotation Speed 1 Answer

Are there any easing functions built into Unity 5? 1 Answer

Quaternion.Slerp only one axis? 1 Answer

Problem with Lerp/Slerp 1 Answer

Slowing velocity in Rotation? 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