One I just cannot figure out
Blitz3D Forums/Blitz3D Programming/One I just cannot figure out
| ||
Here is my problem: I have set a number of items on a plane.They can vary; Lets say 3 are at x=200,y=0,z=500 x=220,y=0,z=650 x=193,y=0,z=576 each item is a sphere 20,20,20:with collision possible. A moveable object starts at x=210,y=0,z=100 Object must move in a straight line but have a height curve. Such as a canon shell (which it is not).Maybe more like throwing a ball. the target would be (in this case)=== x=202,y=7:z=1250 I need to calculate the varoius angles to move in order to determine how to end up closest to the target. If I am not making this clear I am sorry. Would be glad to expand the details if needed. Any help would be wonderfull. |
| ||
Oh --- by the way. I have been using "linepick" with little success. |
| ||
hi try to keep it simple you have DeltaYaw to know how much to turn an entity (Y axis: yaw) to point to another entity. So if you want you may turn your entity a certain percent (say 10%) of that angle and move it forward somewhat to do an enttity to follow another. regards Juan |
| ||
charrua-- Wish it were that simple. I need to get the angle both around (left and right) and over the object. Not just the angle to the "xyz" location. Also,the the location of the objects are not know,they must be found. Not so simple eh. |
| ||
i still don't get the point. You can use a pivot, place it on the Entity1 position and orientation. Record pitch, yaw, and roll, then PointEntity to point the pivot to Entity2 and found the Delta's in any axis. Delta yaw only gives you Y rotation. (But if i'm not wrong you are working on a plane, so X and Z axis aren't needed ?) simply making an entity point to another (slightly on each frame) and going forward you will end with Entity1 reaching the position of Entity2. but, i think i didn't understan what you need, sorry. explain further please Juan |
| ||
I have trouble following your question. Maybe you could create a small program that uses only stuff like CreateCube and EntityColor to demonstrate what you want? |
| ||
OK...thought maybe it would be tough to explain. Try this explanation You have five trees at different locations. You want to throw a ball that will be sure to MISS all three trees. By going over or around. It can be aimed as needed but the vertical pattern would obviously be a set constant.(as defined by force and gravity which I have incorporated into the movement ok) You want to find which direction to throw the ball to have it land at a point of your choice,OR CLOSEST TO THAT POINT. Best I can do. Thanks for taking the time to think about this. |
| ||
the y position of the ball will be dictated by gravity, but the ball always go forward or can it have a curved path? at first you may check if a tree is between the destination point and then decide if you throw the ball over the tree or trying to evade the tree by one side. If the ball can change directon on the fly, then you can precalculate a set of x,z positions... ? i supose that your problem is what about if there are many trees in between and you want to find a path to reach your target that evades all posible obstacles... if so, probably you may have to learn some A* (A star) algoritm: http://www.policyalmanac.org/games/aStarTutorial.htm but probably this aproach isn't apropiate for a ball flyin on air. probably you may find some secure points and then interpolate with bezier curves in between, but i thik that there will be a simple solution. i recognize that still dont figure what is you question. Juan |
| ||
ok charrua thanks. The ball cannont vary from original path in a left-right direction and of course flys in a defined arc. |
| ||
so, basically you need a way to calculate the first impulse and the angle from the horizontal to reach certain distance: ballistic and no more. it all depends on the equations you use to simulate gravity. When you choose an angle it has 2 perpendicular components, one in the y axis (over wich gravity as influence) and one in the forward direction (if friction=0) the forward velocity should be constant. Based on gravity, you know that the object should go up until it reaches it's higest point and then go down to reach the grond. The amount of TIME for the Y movement and the forward direction is the same so you yave 2 equations. Basically you can Calculate Distance as a funtion of the Horizontal angle using the ecuation for the Y behavior and the fact that Distance = ForwardVelocity * Time (being Time the same time you can calculate from UpVelocity and gravity) but, i can't give you an exact equation jus because it all depends on your fisics. regards Juan Last edited 2011 |
| ||
As I said ,I know all the things you stated. I guess I cannot explain clearly what I NEED to get. Thanks anyway. |
| ||
um, so you have a point at which the projectile takes off (a), to test if there is stuff in between (a) and the target (b), create a child pivot (c) for (a) at the position of (b). then do a line pick from (a) to (c) while rotating (a) side to side like a radar, and if there is no open path from (a) to (b) then use the most distant object from (a) found or the closest object to (b) found during the scan. I don't think line pick is perfect though, uses spheres and rectangles(I think) so if there is a tree with branches I'm not sure if it will see the pivot directly behind it. |