Jump to content

Spinning Entities around Origin


Recommended Posts

I've got this question and it's more of a math question (I just got into high school so please don't expect too much).


I have a entity that grabs nearby blocks (block entities like sand) and spins them around the entity. Kind of like a tornado that just spins blocks in circles.


How can I find the X and Z position of these spinning blocks based on - the position of the entity controlling these blocks, the radius/distance between the entity and the flying block and the rotation orbit?


I currently found something similar to this:

this.targetX = this.posX + xMod*orbitRadius * Math.cos(orbitDegree);
this.targetZ = this.posZ + zMod*orbitRadius * Math.sin(orbitDegree);


but it didn't work (pushed out all the blocks outwards and that's all).

Link to comment
Share on other sites

Tried inverting the addition to pull in.  And add an addition inside the trig functions to rotate?


What?! I don't really understand..


What I'm trying to get is to have blocks orbiting around an origin. I'm not sure what math I have to do to calculate the position of where these blocks should fly.

Link to comment
Share on other sites

You are also multipying by xMod/zMod, no clue what those are or what the surrounding code looks like?


Those two variables are multiplied. They are either -1 or 1. If the position is negative, the xMod and zMod will be negative. This is used to make sure they fly the correct direction. \


The surrounding code aren't really related to this. I was testing and trying to make it orbit. Basically we have an entity that is walking around. If the entity goes close enough range to a specific position, the position will pull the entity towards it orbiting around it. Kind of like a block that has massive gravity.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.