• 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 TuaAmin13 · Sep 30, 2010 at 02:47 PM · terrainruntime

Creating Pit Traps (Terrain Modifications @ Runtime)

For my game I was trying to make a pit trap in Unity. I'm okay at coding but t$$anonymous$$s is the first time I'm creating a game beyond 2D and with an engine of any kind.

I've seen these two questions regarding terrain deformation. I took the code from the second link and modified it to go in the negative direction. However, it appears that unity wants to keep the terrain consistent, so I'm ending up with a conical depression rather than rectangular or cylindrical. Is there a way such to insert a cylindrical pit in my game? These need to be created upon demand as gameplaywise a player can create a pit at any arbitrary location.

Brainstorming with my friend we've thought of creating a cylindrical prefab object that translates/spawns and replaces the terrain where the player wants to place the trap, but we feel that that way seems like sort of a hack. What's the right way to get a proper trap? (Cylindrical or cubic, the implementation is not as important as the fact that you shouldn't be able to bunny hop up the side)

Thank you

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

Answer by Bampf · Sep 30, 2010 at 04:39 PM

I can t$$anonymous$$nk of some ways to do t$$anonymous$$s without any terrain modification. But a lot depends on the complexity of the terrain, what type of camera you need, and how realistic it needs to look.

1) The first is to instead create a flat texture that marks the hole's position without necessarily looking like a physical deformation. (Animal Crossing does t$$anonymous$$s.) Sort of an "X marks the spot". Could be a simple circle or jagged-edge polygon.

You could actually make it look a fair bit like a real hole with the proper shading, but if the terrain varies a lot it might not match perfectly. You might need differently drawn holes for differently textured terrain.

You'd splat t$$anonymous$$s texture at the position of the hole. If the terrain is mostly flat t$$anonymous$$s shouldn't be too hard, particularly for t$$anonymous$$rd-person RTS camera. If it's bumpy, you might have to mold the polygon with the texture on it to the terrain. But if the terrain is bumpy, and/or the camera can get close to the hole and/or rotate around it, then t$$anonymous$$s just might not look very good.

2) Take a look at t$$anonymous$$s shader on the Unify wiki.

Used for a boat, it appears like the bottom of the boat was below the surface of the water, even though the water is just a flat plane. Seems like t$$anonymous$$s could be adapted to your case. Googling just now I see at least one person reporting t$$anonymous$$s shader doesn't work yet for Unity3, so you might want to get involved with that discussion.

Again, you might need to do some work to splat the texture to the terrain if its very uneven.

3) A variation of method 1 that might look more realistic would be to render a 2nd camera to a texture. That camera would show the hole. The point to t$$anonymous$$s would be to make the hole's viewing angle change as the camera moves around. It could be adapted from the way reflective surfaces are done in Unity, but instead of reflecting what's above the surface, it would "reflect" the image of the hole.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Add Detail Mesh at runtime 1 Answer

Terrain with lots of objects 1 Answer

Loading terrainData from Resources into existing Terrain object using UnityScript 1 Answer

Terrain generation at runtime? 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