• 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 gurrajgurraj · May 05, 2019 at 09:39 AM · instantiatebounds

How to implement Earthbending?

Hi!

I'm making an Avatar sort of game with bending mechanics and I have been struggling for a while now with implementing a good-looking rock throw attack. There is very little documentation about spawning things so they come out of the ground then forward so if you could shed som light on the matter please do.

The rock in question.

Here is my current script:

 groundextentbounds = groundcollider.bounds.extents;
         groundmaxbounds = groundcenterbounds + groundextentbounds;
         groundcenterbounds = groundcollider.bounds.center;
 
         rockextentbounds = earthcollider.bounds.extents;
         rockcenterbounds = earthcollider.bounds.center;
         rockmaxbounds = rockcenterbounds - rockextentbounds;
 
     }
 
    
     // Update is called once per frame
     void Update()
     {
         SpawnLocation =  player.transform.position - rockextentbounds + player.transform.forward * 5;
 
         if (Input.GetKeyDown(KeyCode.E))
             {
             Instantiate(Earthrb, SpawnLocation, player.transform.rotation);
             
             }

Comment
Add comment · Show 3
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 Casiell · May 05, 2019 at 05:04 PM 0
Share

You didn't really explain your problem. Documentation for Instantiate is good, it says everything there is about this method. Any displacement and movement you have to do yourself.

As a side note to see your link one needs to have an account on that side. Upload picture to a site where you don't need an account (like imgur) or directly here

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by TheXWolf · May 06, 2019 at 01:33 PM

This is a very complicated question. First you need to instantiate an object and then most likely watching the transform or the rigidbody move it to a position. (Depending how realistic vs accurate you want.) Or another way to do it, would be to have it be part of an animation.

Spawning in an object that has an animation on it that moves it in and fires itself forward. If you're doing this with physics logic it would be quite complex. Most likely you'll need 2 scripts, the one instantiating it shouldn't really know it exists, simply create it and let it go. A second script on the object itself handling its position either via physics or straight transform movement.


I would suggest looking up Transform.Translate as well as Rigidbody.Velocity. Additionally you'll need to track when it's raised high enough. Again, the simplest way would be spawn in the object animating it's relative position, and affecting the rigidbody velocity at the point where it starts moving forward rather than up so it continues.

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

127 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

not working- GameObject.GetComponent(MeshFilter).mesh; 1 Answer

How can I determine an object of prefab's size (for positioning when instantiating them) 2 Answers

Are my bounds right world position in this case ? 1 Answer

Instantiate within boundaries of Mesh shape 2 Answers

Checking if object intersects? 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