# 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);

}

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.