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
1
Question by maikkel · Oct 12, 2010 at 03:00 PM · movementcurveturn

turn around 90 curve with forward/rotation

I'm trying to do some kind of tower defense game.

The map is created from blocks (prefabs) and then combined.

In each corner there's a waypoint-GameObject so the Enemy knows its path.

the movement is achieved by translation (speed * Time.deltaTime).

I'd like to achieve a smooth turn around the 90-corners while keeping the speed (as variable in the enemy-Object). what's the optimal way to achieve this? Do I need to use complicated trigonometry to calculate each movement segment around the curve (if yes, are there any examples, and isn't this too cpu-expensive if there are many objects turning at the same time)?

Any ideas?

Here's a little illustration how it's supposed to be: (movement along the black line, curve between the blue lines, waypoint in magenta. the red lines are on the texture (ignore them))

alt text

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

2 Replies

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

Answer by skovacs1 · Oct 12, 2010 at 05:26 PM

Here are some options for how to round corners:

  1. Include more waypoints and fake a curve. Simple, but awkward.
  2. Include a directions to raycast against for corner sections. Assumes you know the structure of your walls, that you have colliders and adds raycasts, making it simple, but costly.
  3. Set up a bzier curve or NURBS system for your waypoints. Less simple.
  4. You could use iTween which has all of the facilities needed for this. Simple (Look into PutOnPath, PointOnPath, MoveTo with movetopath).
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 maikkel · Oct 12, 2010 at 08:29 PM 0
Share

Thank you, i'll look into these solutions (i love bezier curves but calculating them myself is a little tricky, unity should really have some sort of spline-tool), i will look into those and maybe use itween (i use it for other stuff already)

Btw: I think iTween is free. You can just download it (and its on google code so it must be open source...). But i actually donated a little bit, cause i like it a lot (i'm co$$anonymous$$g from flash (R.I.P.), it works much like the tweener library in ActionScript)

avatar image skovacs1 · Oct 12, 2010 at 08:39 PM 0
Share

Sorry about the mistake on the itween stuff. I was looking at the examples on their site which are 2.00 USD apiece.

avatar image
1
Best Answer

Answer by ckfinite · Oct 12, 2010 at 05:53 PM

You should not need to use trig, unless you calculate the texture's curves at runtime.

What you could do is determine the turn rate for the object. To do this, you will need to know the speed of the object and the radius of the turn. Calculate the circumference of the circle that the curve is part of, divide it by 4, and that is the distance the object will need to travel. Then, divide this number by the speed of the object, to get the amount of time the object will take to move through the curve. Then, divide the angle of the turn by this time, resulting in the amount of degrees per unit is required. Then, add this number (divided by deltaTime) to the correct rotation every tick.

Comment
Add comment · Show 1 · 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 maikkel · Oct 12, 2010 at 08:20 PM 0
Share

Thanks for the tip, this seems to be the easiest solution (since the turns are always the same, i can pre-calculate most of it)

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

1 Person is following this question.

avatar image

Related Questions

Move object through set of points 0 Answers

Move object to position, perform action, move back to starting position 0 Answers

iTween for Dynamically Moving Objects around a Sphere 0 Answers

Itween for curved orbital movement? 1 Answer

Rotation and movement? 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