Get Angle ?

Blitz3D Forums/Blitz3D Beginners Area/Get Angle ?

CodeOrc(Posted 2008) [#1]
Hi Everybody,

I looked in the code arc's and could not find what I was looking for, or my feeble little mind could not understand any of it :)

Here is what I need;

1. Get the Angle of the Tri/Vert/Poly that my player is standing on.
2. If the angle=>60 degrees the stop my animation as in, he cannot climb that hill.

thats it, but I am confused on how to do this.

Any help would be greatly appreciated.

THX !


Dreamora(Posted 2008) [#2]
Use Linepick vertical down and then pickedy
Thats will allow you to calculate the angle atan / atan2


CodeOrc(Posted 2008) [#3]
Could you possibly provide a code sample for myself and others?

:)


Stevie G(Posted 2008) [#4]
LinePick entityx(player ), entityy(player ) + 10 , entityz( player ), 0,-100,0

If PickedNy < .25 then
{ this is a pretty steep slope }
endif

You don't need atan2 etc.. that's just overkill. Just use the pickedny() .. you'll need to play with the .25 value but 1 = flat , 0 = vertical.

Stevie


CodeOrc(Posted 2008) [#5]
so do I need to make my player "pickable" or my terrain mesh?

and thx for your help :)


Stevie G(Posted 2008) [#6]
The terrain mesh.


CodeOrc(Posted 2008) [#7]
I did that and PickedNY has no value assigned to it. And I did assign entitypickmode 2 to my terrain.

In my Code I have "my_angle" as a global # to capture the value so I could see the proposed angle of the terrain vert, and why it was not working. And my "my_angle" variable shows no value for PickedNY:

your code:
LinePick EntityX(player ), EntityY(player ) + 10 , EntityZ( player ), 0,-100,0

my_angle=PickedNY

If PickedNY < .25
;the .25 value but 1 = flat , 0 = vertical
EndIf


big10p(Posted 2008) [#8]
You need to use brackets with PickedNY(), else the compiler thinks you're referencing a variable called PickedNY, not calling a function.


Stevie G(Posted 2008) [#9]
EDIT : sorry - you have the # there already. My bad - forgot about the () part!!


CodeOrc(Posted 2008) [#10]
ok, that works great on my terrain, allowing me to determine at what angles my actor can/cannot go up.

But, a new problems arose..I am using "EntityPickMode enemy,1" for my badguys so when they get into my crosshair it changes the crosshair color.
"pictentity=CameraPick(camera,MouseX(),MouseY())

If PickedEntity()=enemy1 ShowEntity target122"

Well now that my terrain is pickable, it wont let the pickmode for my badguys function. It acts like it's being overran by something and is ignored.


CodeOrc(Posted 2008) [#11]
I may have found a temporary fix, I enable pickmode for the Terrain>run the angle check>then un-enable pickmode.

Will this be a performance hit ?


Ross C(Posted 2008) [#12]
It may be the way your code is structured. If you can paste the code you are using it might help. It shouldn't be any performance hit disabling pickmodes.


CodeOrc(Posted 2008) [#13]
Ok, i fixed it, I zigged instead of zagging...lol

Thx to all for helping, this is working great.