Thanks to the guidance of some very helpful individuals, I managed to get turret tracking set up exactly how I had hoped however I’ve run into another problem. Using .alignAxisToVect() doesn’t leave any room to set up a variable to keep track of the turret’s orientation (example, to lock rotating past -1 Y so the guns won’t shoot through the ship)
So the question is, if you’re using the ship as a reference point, is there a way to make the left cube return a negative number, and the right cube return a positive number? If so, the “shoot through the ship” problem would be very simple to solve. Sorry for the “newby” questions; this is my first attempt at making a serious, complex game with BGE (I came here from Unity as I absolutely DESPISE javascript and C#, heh). And an off-topic question as it’s been bugging me for some time- is there a way to disable auto-save on the forums? Every few seconds when the thread decides to auto-save my text, it’ll lock up my browser until it finishes, making typing anything of length a fun and exciting experience.
I believe you can use the dot product of the forwards vector against the line to the point. However the line to the point must be to the point at the same height
Sure it is. I assume left and right is on the x axis. Retrieve a vector along the local x axis (in world space) of the current object and do a dot product (also called scalar product) with the vector from the current object to the object in question.
If the dot product is negative the object is left if it is positive it is right. If it is zero the object is before,behinf,over or under the current object.
I think you should understand the math behind this rather then asking for ready to use code. Therefore I recommend to check wikipedia for dot product.
Anyway here is a demo. It includes some helpers to show how it works. They are the children of Alignment.leftRight.
The mathematics itself consists of three line Python code. I’m sure it is not that hard to find it.
You can use the included object to detect up/down and front/behind as well. Just parent it with the according orientation. It measures along Y-axis as the empties representation circle faces along Y. This makes it easier to see where the alignment plane is.
yep i understood the math, and i knew it couldnt be larger than 5 lines, its just that im not that experienced at python and sometimes i need a little push, thanks anyway Monster
You need to break it into a “base” and a gun, so that the 2-part motion can happen, but its easy, just add it, change the targets of the 6dof and messages
BluePrintRandom, why are you writing about joints? This has nothing to do with the topic. And please do not add several posts. You can simply edit your last post.