Jump to content

My 3rd Person Character Controller


Clackdor
 Share

Recommended Posts

Hi Clackdor,

 

Very good I see you have some decent object avoidance. There are just a few things I'd like to point out. Tree of them is really easy to fix. The other not so.

 

1. The camera can go upside down. Try limiting the X rotation of the camera

post-3220-0-96569600-1325827933_thumb.jpg

 

2. Your collision with the floor is very good. However you don't have many walls in your scene so you may not have noticed that if you get too close to a wall the wall disappears. I managed to position the camera against the structure to show what I mean. As you can see some of the structure is invisible and the camera is looking through this. I don't know if there are any conventional ways of solving this but I came up with a way myself. Check my youtube channel for Third Person Camera stuff I think I explain it somewhere in there.

post-3220-0-15603900-1325827947_thumb.jpg

 

3. What Josh said. Curve() should not be too hard to implement

 

4. Character needs to strafe. Difficult to position the character freely without a strafe left and strafe right option.

 

Otherwise its coming along very nicely. My camera is not perfect but I think it is good enough for now and I'll make it better after I program some gameplay. I'd suggest just do points 1, 3 & 4 and then move on to something else for now. Point 2 will be necessary in the long run but its not generally a quick fix and may take some time.

STS - Scarlet Thread Studios

AKA: Engineer Ken

 

Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now!

Link to comment
Share on other sites

Thanks a lot for this feedback, Ken!

 

I will play around with the camera collision some more. It's only been implemented for a day.

 

The strafe code is actually commented out. This character doesn't have a strafe animation. I'll have to add it.

 

I also need to reverse the walking animation so it looks more correct when she is walking backwards.

Link to comment
Share on other sites

I have been struggling with how to stop my camera passing thru walls and obscuring the view.In one commercial game I have this problem is solved by raising the viewpoint of the camera when near walls so that it looks down on the character from above then going back to eye level as the camera moves away from walls.

 

Can someone direct me to a code example??

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Link to comment
Share on other sites

Taken directly from my source.

 

pivot2 is an entity that is on a line between the character and camera, but positioned a little ways out so that the ray does not hit the character mesh. It basically makes a circle around the character mesh.

 

Because the TPick raycast collision location is given in global coordinates, I position a pivot3 at that location instead of doing Vec3 math and figuring out local/global conversion.

 

if (EntityPick(&raycast,pivot2,10.0f,1)) {
       PositionEntity(pivot3,Vec3(raycast.X,raycast.Y,raycast.Z));
       PositionEntity(camera, Vec3(0,0,Min(camz, EntityDistance(controller,pivot3)-0.7f)));
   }
   else {
       PositionEntity(camera, Vec3(0,0,camz));
   }

 

FYI, I decreased the frequency of the images shown in number 2 of Ken's comments by adding that 0.7f modifier shown above and also adjusting my near camera frustum range to 0.01.

Link to comment
Share on other sites

  • 2 weeks later...

I'm guessing you have Flip(1) in your code. tkunze found that it makes it so the game doesn't update for me unless I move the window.

 

Huh? Flip(1) means v-sync is on. Flip(0) v-sync is off

 

Also Clackdor you can completely eliminate pic number 2 if you use multiple raycasts. as shown in the following picture:

 

post-3220-0-10516500-1326885142_thumb.jpg

Note: When I say in the pic fire 4 'arrays' I actually mean ray-casts lol.

 

Off course this is just my method and by no means the only way. However, it does eliminate any possibility of things being clipped on the sides above and below.

STS - Scarlet Thread Studios

AKA: Engineer Ken

 

Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now!

Link to comment
Share on other sites

I did what Rick did. I will play around with your suggestion, though, Ken. It's not too bad now, except when the character backs right against a wall.

 

I've also moved on to focusing on other gameplay elements and shooting for a first game release this spring. It's sort of a stupid pac-man game that Rick gave me the idea for a while ago, but it does do a good job of exercising the old programming joints and getting used to Leadwerks commands.

Link to comment
Share on other sites

Yup, that's it. I can make a video if you want to see it in action.

 

No that's fine. I know what it does. I'm just confused by what you were saying.

 

"the game doesn't update for me unless I move the window"

 

not sure I understand what you mean by that because it sure doesn't do that on my computer. Probably just a misunderstanding lol

STS - Scarlet Thread Studios

AKA: Engineer Ken

 

Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now!

Link to comment
Share on other sites

I run the game. It seems frozen. I press the buttons to move. Nothing seems to happen. I then move the window. The window updates to the current frame - no animation, just jumps from the old to the current one. Press more buttons. Nothing moves. But as soon as I move the window it updates again. I'm probably one of very few people who this happens to.

Link to comment
Share on other sites

I did what Rick did. I will play around with your suggestion, though, Ken. It's not too bad now, except when the character backs right against a wall.

 

 

Which is why using a single cast followed by a camera move forward will not eliminate clipping, it may reduce it on some flat surfaces but posts and pillars are a different matter, and as you know when the 3rd Person character is close to, for example a wall, you will find the camera inside the characters head looking out. I use an array similar to that in Kens illustration.

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

I run the game. It seems frozen. I press the buttons to move. Nothing seems to happen. I then move the window. The window updates to the current frame - no animation, just jumps from the old to the current one. Press more buttons. Nothing moves. But as soon as I move the window it updates again. I'm probably one of very few people who this happens to.

 

Oh wow. Thats odd :(

STS - Scarlet Thread Studios

AKA: Engineer Ken

 

Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now!

Link to comment
Share on other sites

I'm afraid it needs some refinement before I can release it. I would also need to define some parameters, for instance, its a player controller/animation controller. Should I separate those out? Plus, so many people are quirky about their controller, that I might just consider throwing out there as a code dump for others to edit to fit their needs. But it seems like most developers write their own.

Link to comment
Share on other sites

I was going through some old Buffer code yesterday with regard to some CCTV ideas myself and Macklebee had been working on, a few hours ago I found my test code for one of the first 3rd Person cameras I did using a raycast array, so to show the difference between using a single cast and an array of casts I combined the two codes to show the advantages of a raycast array.

 

The first section shows the cam position being generated by a single raycast, the top left screen shows the actual camera view, the green sphere in the main screen is the calculated position of the camera. In the second section an array of casts is used, again the top left screen shows the actual camera view, the green sphere in the main screen is the calculated position of the camera and this time the red spheres mark out the boundary of a simple raycast array. Kens Graphic shows how to layout a basic array.

 

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

Did Josh ever say if LE3D or even LE2 would fix the ray radius issue because that seems like it could help in a situation like this.

 

 

"It's not supported in LE2. This is actually one of the things I am working on in LE3. It's a lot harder than I expected, because nobody writes spherecasting code for an irregularly scaled sphere against a triangle."

 

 

Unless the Spherecasting function allows for the return of data from individually picked points which would be required to do the contrast and compare needed for this method, I dont think it would be of any benefit. If you use Kens basic array in his picture its a total of 4 casts and some basic maths, and covers only a relatviely small portion of what would be the surface of a sphere .. only flatter.

 

Thanks Marley. Good demo.

 

You are welcome, I thought it might help visualise whats been said, but you are on the right track though.

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...