Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Functions related/helpful to trigonometry?

Eaglebird Cameron
YTMND *********
Join date: 1 Jul 2006
Posts: 68
07-27-2006 08:20
I'll get straight to the point.
I have myself, and a turret. The turret copies my rotation in relation to either a local axis or a line drawn from me to the turret. So basically, whichever way I look, the vector of the turrets view is perfectly parallel to my own.
This is not good.
The turret is controlled in mouselook.
I can't apply any trigonometric functions because I only know two things:
My angle which the turret copies, and
the distance between myself and the turret.

If I look at a point in space, the turret is looking elsewhere, because its view is parallel to my own. However, it should be looking at the same point I'm looking at. Well, this could be achieved through some trig if I knew the distance from the point I'm looking at to myself or to the turret. A simple, quick, law of sines or cosines I suppose.

But there's no way to get a position on the point I'm looking at. It'd be easier to implement into the turrets script, letting it find the distance, but it would still need to know what point I'm looking at.

Is it at all possible or likely that you could add something like llGetAvatarViewPoint or something, or is there a way to find the distance with other functions?
Torley Linden
Enlightenment!
Join date: 15 Sep 2004
Posts: 16,530
07-28-2006 11:22
I've moved this to Scripting Tips for further discussion to see if anyone has any bright ideas. :)
_____________________
Monkey Edge
Registered User
Join date: 23 Apr 2005
Posts: 69
07-28-2006 13:33
well im clueless on the workings of trigonometry, but couldnt you make the/a sensor on the turret detect your distance from it and then look at your veiw plus offset?


hope it helps
_____________________
What do today what you can put off till tommorrow
But.......
What is today but yesterday's tommorrow
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
07-28-2006 14:13
Maybe look into the camera functions - there's soem stuff that lets you find where the avatar's camera is pointed, I think. That might give you the coordinate you need, and from there you can calculate the rotation required on the turret?
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
07-28-2006 14:31
I think he's after the position of the first thing the line from the avatar camera in the direction the av is pointing hits. And I don't think there's a way to get that, not without some ugly kludge - like sending probe prims shooting out from the av and reporting back the position where they collide with something.
_____________________
-Seifert Surface
2G!tGLf 2nLt9cG
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
07-28-2006 14:41
Some suggestions here:
/13/0c/124946/1.html#post1183492
Angela Salome
Registered User
Join date: 6 Oct 2005
Posts: 224
07-29-2006 00:21
If the turret is an attachment to your avatar's body, it's effectively positioned where you are, and then you can simply use a gun script for the turret.
Eaglebird Cameron
YTMND *********
Join date: 1 Jul 2006
Posts: 68
07-29-2006 01:08
From: Angela Salome
If the turret is an attachment to your avatar's body, it's effectively positioned where you are, and then you can simply use a gun script for the turret.

It's not. :P