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 Jerdak · Jun 16, 2010 at 09:39 PM · raycastrtsprojectionfovradius

Non uniform movement radius

I've built a semi real time strategy game for work. I semi because users are restricted in their actions in turns. Anyways to the point. The user is allowed to move w/in a certain radius of their character BUT that radius isn't uniform at all degrees. The idea is that player can't move as far if they are restricted by say trees, hills, etc. In effect the movement radius becomes a blobby structure.

My problem is I'm not sure how to go about doing this in any sort of quick manner. It doesn't have to be real time but it can't take 20 minutes either.

My first thought was to project rays out from the selected unit and, at a set interval along that ray, shoot a ray cast down through my terrain. This would return a value that I could add to that ray giving my a sense of how many movement points that particular line would cost. But it seems to me that would still be costly. Additionally I've not any sort of idea how you would display something like that on the terrain.

I'm hoping someone might have some suggestions of places to look or similar problems I can reference.

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
3
Best Answer

Answer by · Jun 17, 2010 at 01:01 AM

I've seen this done (outside of Unity) by using a (typically-hex) grid system. Each unit is given a max-move distance and each grid is assigned a move-cost value.

Example Move-Cost values:

Plains = 1
Sand = 1.5
Hills = 2
Forest = 3
Marsh = 4
Cliffs = 6

Then, for example, a unit might have a max-move distance of 12, so it could move 12 along plains, 8 along sand, 6 along hills (etc), or a combination - i.e. the unit could move through 4 'plains' grids, over 2 'hills' grids, and 1 'marsh' grid (a total of 12 'movement points').

You can get even trickier and apply a modifier to grid-types move-cost values for particular units. For example, light infantry (or the equivalent for whatever theme you're using) might have a bonus against cliffs; i.e. they can scale cliffs easier than heavy units, so it only costs them 4 movement points rather than 6.

As for implementation, it would probably be easiest if you could select the unit and then (using the mouse position), the game could attempt to draw the cheapest path (lines) to the grid that the cursor is over.

Of course, this all depends on your intended implementation - do you want a completely free movement system, or grid-based navigation? A player could easily 'game' a free movement system by very narrowly passing any obstacles.

In either system, you'll need to tag the ground with some sort of 'type' and apply a cost factor against the attempted move. In a grid-based system, you can just store each grid ID and type in an array. In a free-movement system, ray-casting to the ground could potentially give inaccurate results, as the unit could completely pass through a higher-cost grid type before the next test interval. As far as performance costs, I'm not familiar enough with Unity to say how detrimental the frequent raycasts would be.

Hopefully these thoughts are of some use to you!

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

RTS camera help 1 Answer

changing camera view 3 Answers

Raycast help! 1 Answer

How to make a minimap camera zone grow bigger and smaller with zoom 0 Answers

Help with FOV script 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