Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Sparky's Player Height

Author
Message
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 11th Jul 2010 00:51 Edited at: 11th Jul 2010 00:53
Hello!

I'm learning how to use sparky's, and I'd say i'm doing well xD

I know most of this example is practically the sliding demo, but I actually wrote all of that myself, but used the same technique.

Anyways, i'm wondering if anyone can run this code, and show/tell me how i would get it so the players line of sight would be level with the top of the box, I have no idea to do it, so that the collision would still be accurate, any insight to this would be really helpful, thanks

PS you might have to change the res, and remove the maximise window line.

Sorry about the lack of comments aswell :/

Thankyou!


Rawwrr. Sig Fail.
Newcastle is awesome
LBFN
19
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 11th Jul 2010 21:27 Edited at: 11th Jul 2010 21:27
Okay, you are actually using a sphere placed at the camera's location to provide collision. Yet, you want to have the top of the box to be at eyelevel, correct?

When it first runs, the sphere falls down on top of the box. I moved the sphere over some, so that it will fall down to rest on the red box.

I then re-sized the box so that it's height is consistent with the sphere. When sc_getcollisionslidey() is obtained, I added half of the collision sphere's height to it, so that the camera is on top of it. The result is that the camera is at the height of the box.



Hope this helps.

LB


Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 11th Jul 2010 22:31 Edited at: 11th Jul 2010 22:35
Sorry, I don't think I made myself very clear at all.

As you can see, I had some code in there for a level, but I didn't want to upload the level because it'd just be harder for people to help, so I made an example level.

What I mean is, if you see the attached screenshot, the player is... a dwarf, of course, I could increase the radius to make the player taller, but that would also make him "fatter".

Have I made more sense now?

EDIT: Infact, I think you've understood me perfectly, and I'm the one who has misunderstood you. xD However, with that method, the camera can go through the ceiling if you jump, because it places the camera above the point of collision.

Rawwrr. Sig Fail.
Newcastle is awesome
LBFN
19
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 11th Jul 2010 23:45
The code you have provided is first-person perspective, and so I expected you would not be looking at the object (dwarf) itself. Your ceilings would have to be pretty low to go through them, but if you're concerned about that, you could place the camera slightly below the top of your collision sphere. Just change the .5 in line 112 so that it is .4. Like this:


If you want to verify you are within the sphere's bounding box, just put in

right after you setup sphere object 1. This will show you the object's boundaries and make it clear the camera is within.


Login to post a reply

Server time is: 2026-07-25 08:13:44
Your offset time is: 2026-07-25 08:13:44