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 Jfaust · Nov 15, 2012 at 07:18 AM · movementvector3movetowardscurves

Adding curve to Vector3.MoveTowards

So for some projectiles I have set up they are using MoveTowards to attack an enemy target.

I would really like to have the projectile curve out the side before tracking down the target.

Earlier I was using the distance to the target to alter the movement of the projectile, meaning the curve would become less and less the closer the object got to the target(which is what I wanted).

This ended up working to some extent, but the curve value would end up slowing down the projectile, whenever it was moving at a certain direction relative to the world coordinates.

It went something like this...

 var distanceToTarget = Vector3.Distance(myTarget.position, transform.position);
 transform.LookAt(myTarget);
 transform.position = Vector3.MoveTowards(transform.position, myTarget.position, Time.deltaTime * latchSpeed);
 transform.position.x += distanceToTarget / 100;

I figured since the object was always facing towards the object, I wouldn't run into issues with just adding a value to the x position. However it acted weird in different quadrants of space, as if it were being used with World.Space. I tried using transform.localPosition, but the results were the same.

any suggestions? this is a pretty bad hack job, I am sure there is a much cleaner solution.

I was thinking of adding a Vector3.right value to it, see if that yields any results.

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
0

Answer by sparkzbarca · Nov 15, 2012 at 08:22 AM

http://answers.unity3d.com/questions/12689/moving-an-object-along-a-bezier-curve.html

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 Jfaust · Nov 15, 2012 at 09:26 AM 0
Share

thank you for the response, it looks promising. I have avoided trying to use splines as I am unsure how they will react when the end point is a moving object. I also fear the computations will be excessive when there is potentially hundreds of these on the screen.

I will run a trial setup and see if I can get it to function how i would like.

avatar image Kerihobo · Dec 07, 2014 at 10:42 PM 0
Share

how did this go? I want to do something similar.

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

10 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

Related Questions

Error Vector3 does not contain MoveTowards 3 Answers

3 coroutines to ease in lerp, MoveToward steady pace, and ease out lerp 0 Answers

Setting target position in Vector3.MoveTowards 2 Answers

MoveTowards inside Coroutine 2 Answers

Convert WASD to local 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