PointEntity Done?
Blitz3D Forums/Blitz3D Programming/PointEntity Done?
| ||
I'm a bit embarrased to ask this as it seems like it should be a blatently obvious sollution, but how could I detect if my camera is already pointed at an object? |
| ||
Create a pivot at the camera positions Point the pivot at the object check the variance in pitch yaw and roll values between the pivot and camera.. That should do it well enough anyhoo!!! :) |
| ||
You could also use the CameraPick command. |
| ||
indeed, I never think of the Pick commands! such use! i do things the hard way Oh, and dont forget to set EntityPickMode on all objects you will want to check :P |
| ||
Or you could do it like this... (not tested) |
| ||
Papa, that was my first suggestion. :P |
| ||
Cygnus its the same idea but without using any pivots ;) BTW Using a camerapick doesn't tell you if the camera is pointing exactly at the entitys origin, it only tells you that any part of mesh is infront of the camera. And what if another entity gets in the way? ;) |
| ||
You could also perhaps make use of the DeltaPitch and DeltaYaw functions. |
| ||
You could use the CameraProject command, and then check if the projectedX() and projectedY() commands are in the center of the viewport. |
| ||
Or if you can you could just put a global variable containing what entity the camera is pointed at, and change it as that changes. |
| ||
Thanks for all that help everyone! My problem is that I'm ignorant in the use of alot of these commands like DeltaPitch, DeltaYaw, or TformVector. The help files arent all that helpful and doing a search in the forums leads you to reading post after post of stuff that usually doesnt pertain to what you're interested in. It's very frustrating to see comments like "You could also perhaps make use of the DeltaPitch and DeltaYaw functions." (not to pick on DJWoodgate of course!) because I havent the faintest idea how I'd go about using them or what they are for. I *THINK* that the term 'delta' might mean a change in something so I'd hazzard to guess that "DeltaPitch" would mean a change in pitch ..?? I've done search after search to try and figure out how to use TformVector stuff but I havent found much in the way of explaining what its for, how its used, etc for someone who is totaly ignorant of it. I've seen a few "now that i understand it i can't believe i've gone this long without it" posts, but so far no bulbs have gone off for me. I even tried looking up "Vector Math" on google. The doctor said my eyes will stop bleeding soon and the brain swelling will go down ... I truly thank Papa Lazarou for his code bit. That is what I was trying to do but I wasnt quite getting it right. His code plugged in nicely. It sounds like Cygnus is suggesting a pick Command sollution. While I've got a faint understanding of the pick commands, I'm no whiz at it and don't quite see what clever bit of coding would be required to use it. I know just enough to get me into trouble is what I'm guess I'm saying ;) Thanks again for the help everyone and sorry to keep asking questions that have probably been asked a billion times already. |
| ||
Well, DeltaYaw/DeltaPitch tell you the angle an object should rotate to to point at another object. If, for instance, you wanted to know if the object was somewhere in front of you,doesn't matter if its a bit off then: Function InFront(Entity,Object,Fuzz=10) If Abs(DeltaYaw(Entity,Object)-EntityYaw(Entity))<Fuzz Then If Abs(DeltaPitch(Entity,Object)-EntityPitch(Entity))<Fuzz Then Return 1 EndIf EndIf End Function Coded it in the message box so who knows if it works. The fuziness is just the number of degrees pitch or yaw the entity can be pointed away from the object. |
| ||
It won't work - you spelt Fuzziness wrong twice! Also I don't think you need to subtract the current pitch/yaw from the delta pitch/yaw. |
| ||
I think you can just call EntityInView(Camera, Object) and the return value (True/False) will give you the answer! Good luck! |
| ||
Why didn't I think of the delta commands... (not tested)Function PointingAtEntity(SourceID,TargetID) If Abs(DeltaYaw(SourceID,TargetID))<0.00001 If Abs(DeltaPitch(SourceID,TargetID))<0.00001 Then Return True EndIf End Function The delta commands don't seem to return 0, but this will do :) |
| ||
You do have to subtract the deltas from the actual angles - check out the example in the documentation: Note that it is returning an absolute angle not a change in angle (which delta would imply). Changed fuzziness to fuzz btw. |
| ||
Oops, yep your right bot builder :) |