# Thread: P3D 2.0 - out now!

1. Originally Posted by schrodinger
MrCyberpunk: thanks a lot for the appreciation
If I get the issue, you'd like to control a projectile by tracking both the left-right angle (Z angle in P3D) and the up-down angle (X angle in P3D). I think that should work ok, so if when firing you set:
projectile Z angle to (OAngle(playerXY,targetXY))
projectile X angle to (OAngle(player(d)Z,target(d)Z) >> where (d) is the Phytagorean distance
it doesn't work right?

(actually, OAngle won't allow you to use (d) to get the X angle, so you'll have to use the Atan2 expression which if I'm not too rusty should be like: Atan2(Y1-Y2,X2-X1))
Yeah I've done the Atan2 method and its still broken. It's probably Gimble Lock (ie. One of the rotational values can't go beyond the required value as such becomes stuck at 0).
I've got a solution for this that works with firefly fine but the way you've implemented it is different because your axis are all different so its thrown me off a bit.
There's a way to calculate all 3 axis using a single Atan2 which would be preferable to the current implementation of tracking it separately.
Whilst I was happy with Firefly and how it worked there, the issue was collision detection. Meanwhile I try to do the same thing in P3D and I have the collisions working great but the gimbles don't line up at all because something is flipping the UP axis which in turn inverts the other 2 axis which is not ideal.

I'll do a public service for everyone. To get tracking working on 3 axis using Atan2 all you need to do is the following:
--- Items below are attributes for the "AIPlayer" object ---

//Where AI is to where AI is shooting at
DistanceX = PosXAIPlayer - PosXTarget
DistanceY = PosYAIPlayer - PosYTarget
DistanceZ = PosZAIPlayer - PosZTarget

//Rotates the AI gun to where it needs to shoot - projectiles are then fired using that heading
RotX= 0 - ATan2(DistanceY( "AIPlayer" ), Sqr(( DistanceX( "AIPlayer" ) * DistanceX( "AIPlayer" ) ) + ( DistanceZ( "AIPlayer" ) * DistanceZ( "AIPlayer" ) )))
RotY only needs to track in X and Y. As such an Atan2 should cover it.

This code works in Firefly.

This is so that when the object moves past the 0 point and into negative its calculated correctly so that the value does invert correctly because it also takes into account height as well. This is how in Fusion you can track an object in 3D space with all 3 vectors simulated. This gets you a heading, apply speed value to it and the projectile moves along the RotX and RotY (I'm not tracking the Tumble because there's no point). I hope you can do something with this because this took me about a month to develop in firefly due to having to figure out how to track it for player and AI (which is different for both. But you already have the player one working so I don't need to share that).

Reason I'm doing this is because I'd like to salvage the work I did over a year ago for firefly and port it into P3D. I really like your collision implementation better its much faster and your lighting engine is better because there's no hard limits.

Hope this helps anyway. And for the firefly users feel free to use that code.

2. Originally Posted by funmaker
i ended up finding the angles set in the projection engine group, I made it how I want it, but now I found a different problem...
is there anyway to stop the weird thing on the side of the screen?
the cubes aren't being rendered at the edge for some reason (these are cube shapes, not cube tiles)
Attachment 25947
if your wondering why the resolution is so low, im trying to make a ds-ish game
Very nice work funmaker!
Mmmm that look weird,
if you're not into the discord channel you might have missed some of the few additional snippets I posted some months ago, to enhance or fix a few issues,
you could try this one and see if there's any improvement:
https://www.dropbox.com/s/p9hzgqv4lu...ustum.mfa?dl=0
(it is a very suggested download for anyone using P3D2.1 by the way!)

in the original code there was an issue in the way the view frustum was calculated (this also slightly improves performances because of a better early-rejection of polygons to render)

if you tried this and it does not work, feel free to send me your .mfa to support[at]lizardking.co
I'm not sure when I'll be able to take a look though :|

3. @MrCyberpunk that's a quite interesting chunk of code I'll like to dissect, in better times, thanks for sharing!

Yeah as you mention I've chosen a quite arbitrary set of conventions for angles, mainly, my goal was keeping it "readable" to a Fusion user having a topdown view of the axes in the frame editor, but this also causes headscratching when you have to implement non-native expressions!

This is weird though, as you only need "yaw" (Z angle in P3D) and "pitch" (X angle in P3D) and not need "roll" (Y angle in P3D) for projectile tracking, gimbal lock shouldn't be an issue, and it shouldn't be so painful to make, unless I'm overlooking something! I'll try hard to find a spot and give it a look (as you can see from my very rarified presence unfortunately I'm not sure when) and post eventual results of this search

4. Originally Posted by schrodinger
as you can see from my very rarified presence unfortunately I'm not sure when
All good. I'm working on many things so I can wait for a solution. Thanks for looking into it.
And I'm more used to Z being roll and Y being yaw which is where its doing my head in a bit lol. (this is how it works in both Maya and Blender).

5. Still couldn't get to tinker with Fusion unfortunately but wanted to add just one thing that popped in mind yesterday: isn't what you need basically what the "look-at" camera does in P3D? >>> always orienting towards a target location
You can check the expressions I used to set the look-at camera orientation for Z and X angles in the camera code - look at camera group, shouldn't that work for your needs too?
(considering obviously the target being not the player XYZ position but the desired aiming XYZ location)

6. Originally Posted by schrodinger
Still couldn't get to tinker with Fusion unfortunately but wanted to add just one thing that popped in mind yesterday: isn't what you need basically what the "look-at" camera does in P3D? >>> always orienting towards a target location
You can check the expressions I used to set the look-at camera orientation for Z and X angles in the camera code - look at camera group, shouldn't that work for your needs too?
(considering obviously the target being not the player XYZ position but the desired aiming XYZ location)
That should actually. I might give it a go. Thanks.
Edit: Nicely done! That fixed it.
AngleX = ATan2(Z_position( "camera_tool" ) - ( Z_position( "Group.Reference Points" ) + height( "Group.Reference Points" ) ), Distance(X( "Group.Reference Points" ), Y( "Group.Reference Points" ), Alterable Value X( "camera_tool" ), Alterable Value Y( "camera_tool" )))

7. Is there a way to "billboard" a static sprite (Foreground Scenery) at 90 degrees angle with a free cam? When i try, it will be invisible.
At 80 degrees angle with free cam i can see that the static sprite do not follow my cam angle.

8. Hello!
Have you tried removing the "C" option from P3D_engine object "multi_options" string? That's the so-called "Cardboard" effect P3D applies to sprites,
removing this character will disable the sprites "squeezing" and just leave them flat, don't know if this can be a solution for your need?
Other than that, there's no additional builtin processing for sprites.
If you scroll some pages back this thread I think I was mentioning a "billboarding" solution with shapes, but perhaps it's not what you were looking for either...?

9. Originally Posted by schrodinger
Hello!
Have you tried removing the "C" option from P3D_engine object "multi_options" string? That's the so-called "Cardboard" effect P3D applies to sprites,
removing this character will disable the sprites "squeezing" and just leave them flat, don't know if this can be a solution for your need?
Other than that, there's no additional builtin processing for sprites.
If you scroll some pages back this thread I think I was mentioning a "billboarding" solution with shapes, but perhaps it's not what you were looking for either...?
Sorry for the late reply Schrodinger. Removing "C" works for me. Thanks!
I thought of "billboarding" solution with shapes before, but now i'm fine.

10. Whoa just as good as the firefly plugin only cheaper you sir are a miracle worker if not for this plugin I would have a harder time making 3D games of my own.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•