|
dmk, Jr. Member
Posted: 05 May 2014 11:06 AM Total Posts: 32
So I have a basic world setup using FirstPersonController… all is good- can look around and walk and strafe and everything.
Now I want to fire things at baddies :D
What would be the best approach for this- my guess is I can use TweenLite to tween an object’s x,y,z values… which I can get from the camera, and then check for collisions? But that’s leveraging some other platform when maybe there’s a better way native to Away3d?
Similarly, I am currently using a Starling layer to hold the gun graphic so it’s always at the bottom of the screen. Is there a more native way to have a sortof Heads Up Display?
|
dmk, Jr. Member
Posted: 05 May 2014 11:26 AM Total Posts: 32
[ # 1 ]
OK- I should have experimented a bit first… nevermind the TweenLite stuff, giving the object a velocity and updating each frame based on passed time seems to work well
However- how do I get the x,y,z velocity based on current camera settings, in order to always make it fire straight away from middle of camera, let’s say..?
|
dmk, Jr. Member
Posted: 05 May 2014 11:41 AM Total Posts: 32
[ # 2 ]
This seems to do the trick…
var bullet:Bullet = new Bullet(material1); var vector:Vector3D = cam.forwardVector; bullet.position = cam.position; bullet.velocityX = vector.x * 1000; bullet.velocityY = vector.y * 1000; bullet.velocityZ = vector.z * 1000;
Maybe my google-fu isn’t good enough, but there don’t seem to be a lot of tutorials for beginners out there…
|
Mr Margaret Scratcher, Sr. Member
Posted: 15 May 2014 06:28 PM Total Posts: 344
[ # 3 ]
You can also use .moveforward, once you’re object is pointed in the right direction..
|
dmk, Jr. Member
Posted: 21 May 2014 11:23 AM Total Posts: 32
[ # 4 ]
Thanks- I ended up using AwayPhysics and giving it an impulse since I also need collision detection etc.
Next question- how to make the floor infinite? Just think like using a FirstPersonController with fly=false and a plane on the ground. How to tile so it always covers the view- is there a class for this?
|
John Brookes, Moderator
Posted: 22 May 2014 12:43 PM Total Posts: 732
[ # 5 ]
You could use AWPStaticPlaneShape, its infinite.
Although you can also just use a huge BoxShape as the floor
|
dmk, Jr. Member
Posted: 22 May 2014 01:20 PM Total Posts: 32
[ # 6 ]
Thanks! Couple followup questions-
How huge can “huge” be?
Does it affect performance or is Away3D built in a way that offscreen stuff doesn’t really affect things so much (i.e. it would be similar to if I hand-tiled it to just create tiles as-needed)
AWPStaticPlaneShape only affects the physics, can’t update the view of a mesh to appear infinite in any way- right?
|
John Brookes, Moderator
Posted: 22 May 2014 02:40 PM Total Posts: 732
[ # 7 ]
Ahh sorry, though you meant the physics side.
Away will cull what isnt in the view frustum. But it has to test so the less testing it does the better.
How big.
Well really you want to design with the small view frustum (view.far distance).
And use as many tricks as possible into foolling the user into thinking its infinite. Skybox,fog, lowpoly/simple background images stuff in the distance etc etc
When you get into really big distances, you will get some flickering/rendering issues. Add some zeros to a plane size and see.
So no not infinite.
It all depends on what look/design your going for.
Simple scrolling effect by moving planes would probably the way to go.
Or you can use a single plane that is added to the camera and update the UVs (so your moving the texture) to give the appearance of moving.
Bit of an open question, it all depends
|