- Home /
I need a 3d polygon between two cylinders
I asked a similar question earlier. But I guess it wasn't specific enough. I need to place two cylinders down as a first person controller. After that I need to select the two cylinders and place a polygon between the two. That is basically what I need. If you have any questions ask. Thank you.
You have multiple technical issues here, and I don't know which one(s) you are seeking help for: 1) cylinder placement, 2) cylinder selection, and 3) placing objects between cylinders. If you are seeking answers to more than one of these, I suggest you break your question into separate questions and do some additional research. Also you need more details. Does the object between the cylinders need to be rotated to match the line between the two cylinders? Does the object need to be scaled to match the distance between the two cylinders? Does the object just appear between the two cylinders or is there some other mechanism? Etc.
Just placing a cube in between the two cylinders with the same Y scale height as the cylinders (1).
The cube does need to be rotated so it can be placed diagonally across the ground.
I have made the code for the placement of cylinders. The reason why I added it to the question is so that an answer doesn't completely miss the target of the question. Its obviously not going to be tailor made, I just thought it would be good to add the implementation of the code so I don't have to completely rewrite the code.
Thanks.
Just placing a cube in between the two cylinders with the same Y scale height as the cylinders (1).
The cube does need to be rotated so it can be placed diagonally across the ground.
I have made the code for the placement of cylinders. The reason why I added it to the question is so that an answer doesn't completely miss the target of the question. Its obviously not going to be tailor made, I just thought it would be good to add the implementation of the code so I don't have to completely rewrite the code.
Answer by robertbu · Oct 01, 2013 at 12:28 AM
Since you did not post code, I can just give you some logic. Given the position of the two cylinders, pos1 and pos2:
var midpoint = cylinder1.position + (cylinder2.position - cylinder1.position) / 2.0;
cube.position = midpoint;
Height is a bit trickier since the build-in cylinder with y scale of 1.0 is two units high.
cube.localScale.y = cylinder1.localScale.y * 2.0;
Thanks for the code I'm gonna test it out real quick.