Unity3D FPS Tutorial to jMonkey

@oxplay2 said:
skidrunner seem to be good candidate for contributor ;) OFC after he will done it :evil:

What you don't think the process should be displayed publicly?

i don’t said it :wink:



i wanted say: keep working to have contributor :roll:

1 Like
@desiquintans said:
I eagerly await your solution for 'gluing' a weapon in front of the camera, and wish you all the best in this endeavour. :)

I am having no luck with the weapon passing into the environment :(
I was going to include a image but my sight is down so no upload!
this week sucks.
@skidrunner said:
I am having no luck with the weapon passing into the environment :(
I was going to include a image but my sight is down so no upload!
this week sucks.


If you just want to show someone a picture then you can use imgur.com

Or stick it in the public folder of a Dropbox.


Well Here is the clipping issue I spoke of.

Looks like you need to either extend your collision size a bit (so the gun can’t extend beyond it), or add some intelligence to the gun positioning so it avoids obstacles…

for a cheap solution try using bucket translucent on the gun (this is dirty, but might work well enough)

@zarchtried that bit then the player wont fit through doors.

Heh, bucket translucent sounds like a sneaky solution. Or putting the gun on the GUI node might work?



One solution would be to cast a ray from the handle to the bottom of the tip of the gun. If it intersects anything (other than the gun) then rotate the gun up and towards you. If it doesn’t then rotate the gun back towards the normal position.



In theory that quite simple algorithm will give you a nice effect where the gun moves to avoid obstacles (although it will still be possible to insert it into scenery it will be harder to do and it won’t stay like that for long which will most likely be enough to fool the eye).

If you want the gun to be drawn over everything you have to disable depthTest on its material.



Putting it in the translucent bucket just means it will be rendered AFTER everything not OVER everything. The depth test still occurs in the translucent bucket.



@zarch way of doing it would make it look more ‘real’ of course, but it’s a bit more complicated.

@zarch and @nehon I like both ideas but I have another. On my gun node witch is moved and rotated with the camera I create two nodes leftHand and rightHand I attach the gun model to one of these. If I create a hand control if you will to control these nodes that on collision rotates inward to a resting position that is in the capsule collision shape and disables the gun control. This would solve the position and would be just as simple and zarch’s approach. what do you think?



PS - I don’t care how complicated a method is I just want this damn thing beautiful.

@skidrunner said:
PS - I don't care how complicated a method is I just want this damn thing beautiful.

Fair enough, your solution sounds good

Well It’s essentially the same idea but rotating sideways instead of up. Sounds like a decent approach to me :slight_smile:

I just found a solution to the hole gun clipping thing :smiley:



[java]

public void simpleInitApp() {

camViewPort = renderManager.createPostView("Camera Default", cam);

camViewPort.setClearFlags(false, true, true);

camViewPort.attachScene(camNode);

}



public void simpleUpdate(float tpf) {

// Game Logic Here…



camNode.setLocalTranslation(cam.getLocation());

camNode.setLocalRotation(cam.getRotation());

camNode.updateLogicalState(tpf);

camNode.updateGeometricState();

}

[/java]



The only thing that kinda makes me upset is that I can not create this ViewPort before the guiViewPort and after the viewPort are created. Oh well I can just make sure not to put the gun where I want to put GUI stuff.

"If only initCamera() wasn't private!"
1 Like

Maybe create a main view instead of a post view? Then it will always be drawn before the gui viewport.

@pspeed do you know how to do that the proper way? When I tried it just drew over all so I saw the fps text but not the rootNode. I even set the ViewPort’s background color to 0,0,0,0 and still couldn’t see through it.

@skidrunner said:
@pspeed do you know how to do that the proper way? When I tried it just drew over all so I saw the fps text but not the rootNode. I even set the ViewPort's background color to 0,0,0,0 and still couldn't see through it.


Sounds like the clear flags weren't set right.

@skidrunner thank you. There is a real lack of WYSIWYG editors in Java, JMonkeyEngine 3.0 integrated game development environment is quite good and your attempt reminds me that it can compete with Unity3D.