Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 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

avatar image gurrajgurraj Casiell · May 05, 2019 at 08:56 PM 0
Share

$$anonymous$$y problem is with the displacement when im instantiating. What I want to do is so the rock comes up from the ground and then flies forward like in the series.

avatar image Casiell gurrajgurraj · May 06, 2019 at 08:06 AM 0
Share

You would have to watch some tutorials for that. It's a simple but quite complex topic and explaining it here would take too long. This would be a good place to start I think

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.

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

Instantiate a sprite inside bounds of other sprite? 1 Answer

Instantiating prefabs within the MeshFilter volume of object 1 Answer

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


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