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 Discussion / How to make collision in with player in a fps game

Author
Message
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 2nd Nov 2008 19:18
i have been looking through different tutorials on fps games trying to get a handle on how to make then and i have everything workin exept the collision with the player i can have walls and objects but all that will happen is i walk through them i have tried using collision with the gun and that doesnt work any help?

I am using pretty much the same basic fps stuff as the first tutorial on this website
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 2nd Nov 2008 20:27
One way I usually use is to have a player object positioned at the camera's position and extending to the floor (just a box will do, but the camera should be inside, so that it can't be seen). Then you can check collision with the player object, rather than trying to figure out if the camera is colliding with everything.

Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 3rd Nov 2008 02:02
ok thanx i'll try it probebly 2morro
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 3rd Nov 2008 18:58
@Celeb1994

BN2 is right, use an object where the camera is for collision detection; but you also mentioned using the first tutorial on the website. Do you mean The Monster Hunt tutorial? If that is the case, it doesn't use collision commands but uses distance checks. If you look at:



you'll discover it is only checking to see if x,y,z are within the stone pillars. If they are, Collide=1 which is a variable used by the program to do something when when you or an object tries to move there. In the early setup of the program, the matrix is 10000 units by 10000 units so each pillar is placed at x*1000 by z*1000 within 9000 units and they are 100 units wide. This DecoCollide function checks if anything is within 120 units of the center of each pillar. It is very specific to the pillars at those very specific positions and is not useful for general collision unless you modify it heavily. So I'm just guessing that you are trying to use this function for general collision and it is not working. But I could be way off and you aren't doing this.

Enjoy your day.
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 4th Nov 2008 05:04
ya i accually took that part out cuz i also took out the pillars because what i wanted to do is make a simple game where you navigate through rooms and try and find the enemy and kill it before it kills you very simple

at first i thought that mite work(modifying the collision for the pillarss) then i realized it would be a amazingly long code haha i knew there was a easier way

does anyone have the code for putting that box in because i tried and i couldnt get the cube placed correctly
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 4th Nov 2008 23:27
Here's one way to do it. Red cubes are objects that can be collided with, arrows to move camera, mouse to steer:



Enjoy your day.
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 5th Nov 2008 21:25
Looks great works great but when i tried to put it into my code my gun disapeered and i can't move here the original File and the one where i tried to put yours in(attachment)

I modified your code a little so i could look up and down, have a running abbilitys and so its w and s that move but that all worked in yours so idk

Attachments

Login to view attachments
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 5th Nov 2008 21:28
Looks great works great but when i tried to put it into my code my gun disapeered and i can't move here the original File and the one where i tried to put yours in(attachment)

I modified your code a little so i could look up and down, have a running abbilitys and so its w and s that move but that all worked in yours so idk

Attachments

Login to view attachments
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 6th Nov 2008 20:31
I haven't gone over all of your code with a fine toothed comb, but I did find a couple of typos? in your movement code in fps3.dba:



Xrotate object 2,ang#
what angle is ang# supposed to be? Is it angX# or angY#? I think this might be a typo.

In this bit of code from the above section:


You have object 1 being positioned with the camera but it looks like you are testing for collision using object 2. Shouldn't object 1 really be object 2 for the positioning? I think you just copied my code and forgot to update the number for the object you were using for the camera collision box.

Enjoy your day.
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 6th Nov 2008 21:41
oh wow ya thats probly it..... i feel dumb now lol well i'm about to try that thanx
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 6th Nov 2008 22:48
dang i tried it and there were a couple other things wrong and i fixed em now it "works" but its really slow until you run out of bullets wen you need to reload it works great uuugggghhh

I also tried just starting over with your code and it works exept the bullet won't correctly both times it has sumthing to do with the bullet

Login to post a reply

Server time is: 2025-06-07 08:27:54
Your offset time is: 2025-06-07 08:27:54