Jump to content

Recommended Posts

Posted

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).

Posted

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.

Posted

Hmm, should not be too hard, done things like that before, but I have no code in front of me currently...

I pretty much do something just like it in my mechanics mod though for rotation purposes.

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.

Guest
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.

Announcements



×
×
  • Create New...

Important Information

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