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.

Newcomers DBPro Corner / Help with Collisions using map created with FPS Creator within DBPRO

Author
Message
Katyman
FPSC Reloaded TGC Backer
11
Years of Service
User Offline
Joined: 5th Oct 2012
Location: Katy, Texas USA
Posted: 29th Jul 2013 00:09
Per the YouTube Tutorial #1: "Creating_a_game_world_and_loading_it_into_DBPro" I was able to create a simple 3D world (corridors, doors, room) using FPS Creator and copying the universe.dbo and other files to use within DBpro. The program works with one exception: The camera moves through the walls and there is no example as to how to prevent the camera to halt on collision. Is there a way to perform this using this FPSC/DBPRO hybrid? I don't know what object numbers it uses or where exactly what to look for within the "Files" directory.

Attachments

Login to view attachments
Katyman
FPSC Reloaded TGC Backer
11
Years of Service
User Offline
Joined: 5th Oct 2012
Location: Katy, Texas USA
Posted: 30th Jul 2013 02:54
I downloaded Sparky's Collision and I followed installation instructions to resolve my collision problem but I am getting Variable name is not valid on any of the Sparky commands. I really am trying to get my FPS I am writing in DBPro working and FPS Creator is a great shortcut for building the world and less code to work with.
Katyman
FPSC Reloaded TGC Backer
11
Years of Service
User Offline
Joined: 5th Oct 2012
Location: Katy, Texas USA
Posted: 30th Jul 2013 21:32
Can anyone assist with showing me how to set up collisions with walls/door/items created in FPS Creator and used within DarkBasic Profession with "load static objects "levelbank\testlevel\universe.dbo",0" ?
Brendy boy
18
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 30th Jul 2013 22:23
did you put sparky's dll in plugins-user folder?

Katyman
FPSC Reloaded TGC Backer
11
Years of Service
User Offline
Joined: 5th Oct 2012
Location: Katy, Texas USA
Posted: 30th Jul 2013 22:49
Yes I did. I was wondering if having 64-bit Win 8 was an issue with Sparky's. The dll is not being recognized and registering the dll does not help.
Katyman
FPSC Reloaded TGC Backer
11
Years of Service
User Offline
Joined: 5th Oct 2012
Location: Katy, Texas USA
Posted: 5th Aug 2013 09:15
I finally got Sparky's dll working. I uninstalled DBPRO and reinstalled and added Sparky's before upgrading to latest edition.

I created a nice test world using FPS Creator and even a Sky Sphere for atmosphere appearance. Now my only problem is what commands should I use to have the camera stop on collision when it contacts the static walls made with FPS Creator. Any attempt I made with various Collision commands either freezes the camera or throws the camera outside the world's boundaries or just flat fails.

Attachments

Login to view attachments
LBFN
16
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 6th Aug 2013 04:50 Edited at: 6th Aug 2013 04:57
It is probably easier for me to create a simple demo for you to look at rather than try and explain it. Sparky's is really pretty simple once you understand everything, but it can be tough to pick up at first. First off, I have attached a universe.dbo file for you to stick in the appropriate folder if you need it. The program assumes the world object is directly beneath the 'player' sphere as it will keep dropping until it runs into the world object. Bear in mind, this world is only an untextured example and is nothing fancy at all.

I changed the keys used to move around the world. Use W to move forward and S to move backward. The mouse still rotates the player. I put in my own player-following camera routine, and it does not check to see if the camera is colliding with anything, so the camera can go through walls. Still, you should be able to learn from this.




Good luck,

LB

So many games to code.....so little time.

Attachments

Login to view attachments
Katyman
FPSC Reloaded TGC Backer
11
Years of Service
User Offline
Joined: 5th Oct 2012
Location: Katy, Texas USA
Posted: 6th Aug 2013 10:11
Thanks LB

I played with it using both your universe.dbo and the universe.dbo I made from FPS Creator. Yours worked but on mine I had to disable gravity and the walls/floors were still not being recognized as objects to collide with. Plus the camera POV always was on the floor and not above. I tried several position camera and object commands but still unable to get a collision hit.

I am including my universe.dbo to look at.

Attachments

Login to view attachments
LBFN
16
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 6th Aug 2013 16:13
The problem is that your world's position is not directly underneath the player object. Try setting the player sphere's initial position to 271.5,50.0,-165.4 and it should work. i.e.:


The sphere should drop right into the world and move around with collision. The world is bright white, so the ghosted sphere is not easy to see at times, but the collision works.

What I did to figure this out is use CONTROL CAMERA USING ARROW KEYS 0,5.0,2.0 in the do - loop and remmed out the call to the MovePlayer() function. I also had it print the x# and z# camera coordinates on-screen so I could see where I was at in the world. I guestimated the Y coord, but I could have easily put in something to raise or lower the camera.

So many games to code.....so little time.
Katyman
FPSC Reloaded TGC Backer
11
Years of Service
User Offline
Joined: 5th Oct 2012
Location: Katy, Texas USA
Posted: 6th Aug 2013 16:51
I did as you requested and using position object player,271.5,-50.0,-165.4 just placed the camera in the corner inside the floor. Changing the values does not have any effect. Now if I comment out this line and use the original command position camera 60,50,-50 then the camera is positioned correctly but I am still walking through walls. I have been reading about commands for cameras and BASIC 3D Object commands and Collision commands, including the sparky dll commands. I just can seem to grasp the right combination of commands to work on this DBO universe. So is there a way of letting the Camera be treated as the Object and register a collision within a static universe.dbo?

Attaching modified DBA file.

Attachments

Login to view attachments
Katyman
FPSC Reloaded TGC Backer
11
Years of Service
User Offline
Joined: 5th Oct 2012
Location: Katy, Texas USA
Posted: 6th Aug 2013 17:17
I finally got the world and collisions working right!! Just two items I need help with. The camera is pointing some degrees low and not straight ahead. If I try to yrotate either the camera or object, movement sends me to the ceiling. Also is there a way to hide the object without having that sphere in line of sight all the time?

Attaching new DBA file.

Attachments

Login to view attachments
LBFN
16
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 6th Aug 2013 19:11
Re: your first post. You set the Y to -50.0, and it should have been 50.0. Might have made the difference.

Quote: "
Just two items I need help with. The camera is pointing some degrees low and not straight ahead. If I try to yrotate either the camera or object, movement sends me to the ceiling.
"


Easily fixed. In the MovePlayer() function, look at this code:

Change it to point camera cx#,cy# + 7.5,cz#. At that point, your camera will be pointing straight ahead. (I changed this in the code I am posting to be 25.0, which seems to work better). Just make the camera Y that you are pointing at the same as it's Y position.

I don't understand what you are saying with regard to yrotating the camera or object sending you to the ceiling. The camera location and position is based upon the player's position. The player object rotates with the mouse. Need clarification.

Quote: "Also is there a way to hide the object without having that sphere in line of sight all the time?"

yes, just use the HIDE OBJECT command right after you create the player object. The object is still there, you just won't see it.

In the latest code you took out the gravity#. You really need that. If you are trying to keep the camera higher, you could always change the code in the MovePlayer() function to do this (add more than 7.5 to cy#). Bear in mind, the collision checks are on the player sphere; if you are considerably higher than it, the camera might go through some low entryways. I ran it at cy# + 25.0 and it seemed to work okay, so I changed the code. I made the player's sphere larger too.

There is a command that states it can keep the camera from colliding with a static object. It is SET CAMERA TO FOLLOW X, Y, Z, Angle, Distance, Height, Smooth, Collision. However, I have not been able to get this to work with Sparky's - I think you have to use DBP's native MAKE STATIC OBJECT and associated collision boxes to make it work. I would not recommend using this, but wanted to mention it to you. I recommend you make a second sphere object for the camera that will perform the same collision checks as is done for the player. I made the player and camera spheres at a size of 20, increased the radius for both and ran it. It works pretty well for keeping the camera from going out of bounds. Here is the code that worked for me:



So many games to code.....so little time.
Katyman
FPSC Reloaded TGC Backer
11
Years of Service
User Offline
Joined: 5th Oct 2012
Location: Katy, Texas USA
Posted: 6th Aug 2013 22:00
Whew! That did it! Thanks! It's been 40 years since High School and I am a bit rusty with the math. I appreciate the help and I will now start on the harder stuff of really building up this world. Making swinging doors with EZRotate will be interesting for sure. I enjoy learning and I know this will be fun to build.
Katyman
FPSC Reloaded TGC Backer
11
Years of Service
User Offline
Joined: 5th Oct 2012
Location: Katy, Texas USA
Posted: 7th Sep 2013 19:36
Hello Again! Quick question: The collision works great, but if i backup into a wall or turn around too close to a wall, I am still penetrating the wall. Is there a slight modification to the equation code to stop me from backing "out" of a room?
LBFN
16
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 11th Sep 2013 19:02
Quote: "Is there a slight modification to the equation code to stop me from backing "out" of a room? "


Yes, all you need to do is increase the value of radius#. Currently, it is set at 10.0, which is half of the collision sphere and would be typical. You can increase it until you no longer can 'back out' of the room. A value of 15.0 seems to work okay, and still allows you to go through the doors.

So many games to code.....so little time.
Katyman
FPSC Reloaded TGC Backer
11
Years of Service
User Offline
Joined: 5th Oct 2012
Location: Katy, Texas USA
Posted: 22nd Sep 2013 07:44
The suggestion is working out great. One question: The collision code listed works mainly with the static world (walls mostly) I added some animated .X doors I found within fps creator model packs and I am walking right through them before they finish opening up. How can I modify the collision code to see these just as well?

Rem ===== Load Great Hall Door #1 here =======
LOAD OBJECT "Great_door.x",31
load image "Great_Door.bmp",4
TEXTURE OBJECT 31,4
POSITION OBJECT 31,1798,543,-1950
YROTATE OBJECT 31,90
SCALE OBJECT 31,80,100,80
Set Object Speed 31,14

There are 4 doors numbered 31 thru 34
LBFN
16
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 22nd Sep 2013 16:18
One way you could do this is to setup the animated doors within a particular group and then check for collision against the group. The 'world' object was placed into group 1. Setup your doors in group 1 and when you check for collision (at MovePlayer() ), use this instead:



Be sure to use sc_updateObject on the doors when they are moving so it has the correct coordinates to collide with.

So many games to code.....so little time.
Katyman
FPSC Reloaded TGC Backer
11
Years of Service
User Offline
Joined: 5th Oct 2012
Location: Katy, Texas USA
Posted: 22nd Sep 2013 17:31
I see where you are going with this. Now I have 4 of these doors with different Object #'s. Each one at a different POSITION so will I need to set up a group for each?

collide = sc_SphereSlideGroup(1,px#,py#,pz#,cx#,cy#,cz#,radius#,0)
collide = sc_SphereSlideGroup(2,px#,py#,pz#,cx#,cy#,cz#,radius#,0)
and so on....
Katyman
FPSC Reloaded TGC Backer
11
Years of Service
User Offline
Joined: 5th Oct 2012
Location: Katy, Texas USA
Posted: 22nd Sep 2013 20:23
I finally got it worked out!! I had to dig a little to find the arguments for Sparky's commands. I believe I am good to go! Wish there was an sc_UpdateGroupObject 1, it would make things easier than typing sc_UpdateObject 5 or more times per object #
LBFN
16
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 22nd Sep 2013 20:39 Edited at: 22nd Sep 2013 21:38
I think you are confusing the call for the collision check with setting up the object in Sparky's. The setup of an object is structured like this:



So, when you are setting the four doors in group 1, you do each one something like this:



It is possible to set the objects up in different groups. However, you will need more collision checks if you do. IMO, I would put it all into group 1 and then you only have to check against that group. If you had another level, for example, you could setup the objects in group 3 and then collision check against group 3 only; that way you only check the objects that are necessary. (I went from 1 to 3 because the player is setup in group 2 in the code.)


EDIT: Okay, glad you figured it out.

Quote: "it would make things easier than typing sc_UpdateObject 5 or more times per object # "


Perhaps you are being facetious, but if you are updating each object 5 times in the code, you are updating way too much. The player object is updated twice if there is no collision (and gravity is applied) and only once if there is a collision. The camera object is only updated once per game loop. The world does not need to be updated, as it is not moved or rotated.

As for the doors, you would only need to update them when they are being animated.


So many games to code.....so little time.
Katyman
FPSC Reloaded TGC Backer
11
Years of Service
User Offline
Joined: 5th Oct 2012
Location: Katy, Texas USA
Posted: 22nd Sep 2013 21:34
Ok I spoke too soon. I got the collision thing fixed, but now I am not allowed to cross through the door openings. I tried adjusting the radius of the Objects (player & Camera) but it's no good. Can you check my code please to see what I might be doing wrong?

LBFN
16
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 22nd Sep 2013 21:46
Sheesh....we keep posting / editing at near the same time.

The easiest way to check how things look is by using sc_DrawObjectBounds ObjectNumber
right after you set the object up. Put this in for each door, run the code and see why you are colliding with it.

I would need your door objects and the setup code you used in order to help you.

So many games to code.....so little time.
Katyman
FPSC Reloaded TGC Backer
11
Years of Service
User Offline
Joined: 5th Oct 2012
Location: Katy, Texas USA
Posted: 22nd Sep 2013 21:50
These are the Door Objects:

[Code]
Rem ===== Load Great Hall Door #1 here =======
LOAD OBJECT "dungeon\secret_wall2.x",31
load image "dungeon\Great_Door.bmp",4
SC_setupOBJECT 31,1,2
TEXTURE OBJECT 31,4
POSITION OBJECT 31,1798,543,-1950
YROTATE OBJECT 31,90
SCALE OBJECT 31,80,100,80
Set Object Speed 31,14

Rem ===== Load Great Hall Door #2 here =======
LOAD OBJECT "dungeon\secret_wall2.x",32
SC_setupOBJECT 32,1,2
TEXTURE OBJECT 32,4
POSITION OBJECT 32,1950,543,-2102
SCALE OBJECT 32,80,100,80
Set Object Speed 32,14

Rem ===== Load Great Hall Door #3 here =======
LOAD OBJECT "dungeon\secret_wall2.x",33
SC_setupOBJECT 33,1,2
TEXTURE OBJECT 33,4
POSITION OBJECT 33,2150,543,-2102
SCALE OBJECT 33,80,100,80
Set Object Speed 33,14

Rem ===== Load Great Hall Door #4 here =======
LOAD OBJECT "dungeon\secret_wall2.x",34
TEXTURE OBJECT 34,4
SC_setupOBJECT 34,1,2
POSITION OBJECT 34,2202,543,-1950
YROTATE OBJECT 34,90
SCALE OBJECT 34,80,100,80
Set Object Speed 34,14

`*****************************
`** LEVEL 1 SECRET DOOR **
`*****************************

Rem ======Load Secret Door #1 here ======
LOAD OBJECT "dungeon\secret_wall2.x",41,3
load image "dungeon\Secret_door1.bmp",3
SC_setupOBJECT 41,1,2
texture object 41,3
POSITION OBJECT 41,2450,540,-1897
SCALE OBJECT 41,80,100,80
Set Object Speed 41,10

[/Code]
Katyman
FPSC Reloaded TGC Backer
11
Years of Service
User Offline
Joined: 5th Oct 2012
Location: Katy, Texas USA
Posted: 22nd Sep 2013 21:56
Sorry about the Code Snippet...I did what you said and there is a diagonal line from the lower left end of the door to the top right like a "do not enter" barrier across the doorway
Katyman
FPSC Reloaded TGC Backer
11
Years of Service
User Offline
Joined: 5th Oct 2012
Location: Katy, Texas USA
Posted: 22nd Sep 2013 22:07
It looks like to me that the collide zone around the door does not follow the door as it slides opens (left to right or right to left depending approach direction).
Katyman
FPSC Reloaded TGC Backer
11
Years of Service
User Offline
Joined: 5th Oct 2012
Location: Katy, Texas USA
Posted: 22nd Sep 2013 22:40
I am sending you the Object file (.X) and Bitmap to try out. I cleaned out all those extra unneeded lines you recommended.
Katyman
FPSC Reloaded TGC Backer
11
Years of Service
User Offline
Joined: 5th Oct 2012
Location: Katy, Texas USA
Posted: 22nd Sep 2013 23:16
I solved my problem. As long as the Collision for that door was active, there would always be a barrier to prevent movement. So I made it that it is OFF until I am in range of the door and once the animation is completed, turn it off.

Katyman
FPSC Reloaded TGC Backer
11
Years of Service
User Offline
Joined: 5th Oct 2012
Location: Katy, Texas USA
Posted: 22nd Sep 2013 23:18
Code got cut off...

LBFN
16
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 23rd Sep 2013 00:50 Edited at: 23rd Sep 2013 02:49
Katyman,

If you paid for those doors you should not post them here and should delete them right away. If the author donated them for free, then it is fine.

Good work on figuring it out. I will take a look at it to see if there is another option.

LB

EDIT: You must be working on a different universe.dbo than I am, as the positioning of the doors is way outside of the boundaries.
One thing I noticed is that when you use scaling with Sparky's, you have to use SC_AllowObjectScaling ObjectNumber after it is initially setup before scaling it.

Since the animation was done within a modeling program and not in DBP, it may be that the correct coordinates for the door will not get reported to Sparky's, and the collision box will simply stay in place while the door itself moves. You could hard-code the moving of the door, but I think the way you did it will be easier to handle, though I do cringe at hard-coding the coordinates the way you have. A suggestion I would have would be to check the player's distance from the door, kindof like a trigger zone. A function I have used that works for me:



Put the following code early in the program, near the beginning:


You call the function like this:


So, instead of checking if int(px#) = 1830 and int(pz#) = -1985, you can simply check the distance from the doors and react accordingly.

So many games to code.....so little time.
Katyman
FPSC Reloaded TGC Backer
11
Years of Service
User Offline
Joined: 5th Oct 2012
Location: Katy, Texas USA
Posted: 23rd Sep 2013 01:28 Edited at: 23rd Sep 2013 01:34
LB

Removed d/l link just in case. I proceeded to modify all the doors like Object #31 and it is working so far. It may be unorthodox but it seems to work. But if you can recommend a better method, I am ready to learn. Thanks for the assist!!!

UPDATE:
I will try that on Object 31. Less coding!! Nice! Eventually I will get the hang of the command. Two months ago all this looked like Calculus to me. Now it's looks more like Advanced Algebra. I am shooting for an "A+"
LBFN
16
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 23rd Sep 2013 01:30
Katyman,

I edited my post at the exact same time you posted! This is too funny. Anyway, gave you something to consider.

So many games to code.....so little time.

Login to post a reply

Server time is: 2024-03-02 17:07:26
Your offset time is: 2024-03-02 17:07:26