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 / the camera

Author
Message
Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 28th Mar 2010 22:32
OK you guys are gonna start to get sick of mee soon,

I been trying to find how to get the camera to collide and slide with the objects it hits, at the moment it spends alot of time outside the walls of my object. I did look up a thread on sparky's and camera finding this command :

SC_SphereCast(dbCameraPositionX(),dbCameraPositionY(),dbCameraPositionZ(),oldX,oldY,oldZ,50,0)

But it comes up as an unrecognised command, is there something wrong with the line or is it an obsolete line from an older version?

Windows 7 64 bit, AMD Phenom II x4 Black edition, 4 GB Ram, Radeon HD 4650, 540 GB HDD

I can see from your smile, you're not here for the sunset.
Torgoth
16
Years of Service
User Offline
Joined: 16th Dec 2007
Location:
Posted: 29th Mar 2010 03:12
Did you download the plugin? You have to download Sparks collision dll before you can use sparks physics commands.
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 29th Mar 2010 03:14
Quote: "But it comes up as an unrecognised command"


Hi friend..Your Pc dosn´t recognize this comand because you have to install first a Dll.This Dll is free, and you can get it just searching for sparky´s collision...any way here is a link.Good luck

http://forum.thegamecreators.com/?m=forum_view&t=31051&b=5


cheers.

I'm not a grumpy grandpa
Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 29th Mar 2010 13:17
Yes yes i have sparly's collision, i know how to make camera collision normally, i wouldn't be looking up camera collision with sparky's if i wasn't using it... and i did mention that
Quote: "I did look up a thread on sparky's and camera finding this command :

SC_SphereCast(dbCameraPositionX(),dbCameraPositionY(),dbCameraPositionZ(),oldX,oldY,oldZ,50,0)"


Surely that gives away that i was specifically looking for sparky's collision information?

Windows 7 64 bit, AMD Phenom II x4 Black edition, 4 GB Ram, Radeon HD 4650, 540 GB HDD

I can see from your smile, you're not here for the sunset.
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 29th Mar 2010 15:38
Sorry Levanthus !! ...you are righ...I checked it now and it seams to be an obsolete or wrong command


back to code

I'm not a grumpy grandpa
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 29th Mar 2010 18:21
I do not see anything in the help files for Sparky's regarding a specific camera - collision command. For SC_spherecast, I get:

return integer=SC_sphereCast ( objNum, oldx, oldy, oldz, x, y, z, radius, excludeObj )

I don't know if there is a different version of sparky's for DarkGDK, but the dbCameraPositionX() sure sounds like it is for the GDK.

Why don't you place a sphere at the camera's location, hide it and check for collision against it? You would have to move the sphere with the camera, but it should work fine. You could make it as big as you want the collision radius to be.

luskos
16
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 29th Mar 2010 23:20
It looks just like LBFN says, command that is for DarkGDK only.The prefix "db" is used in DarkGDK, i think...

Where there is a will, there is a way.
I often edit my posts, that`s who i am
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 29th Mar 2010 23:32
@Levanthus: You're using DBPro, right? The code you posted is for DGDK. Try the DBPro equivalent:

The command didn't work for a few reasons. First off, you need to put the result in some variable because SC_sphereCast() returns an integer (hence "Collision="). Second, dbCameraPositionX-Z() are not commands in DBPro, so you can't expect them to be recognized.

This is what happens when you copy and paste code, expecting it to work. It doesn't. This is a beginner mistake and can be avoided by learning all you can from other people's code and then writing your own, instead of blindly copying code into your own project.
Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 30th Mar 2010 15:17
Uh... i WAS trying to learn from other peoples code, i wasn't blindly copying others code i was trying to find ways to make it work for me, I have only been using sparky's for like 1 day and was trying to figure out HOW it worked and by ASKING people i'm trying to understand, personally Kira i think your comment was somewhat rude.

All i was saying is looking through help files i couldn't find any commands for camera collision and when i did a search for sparky's and camera collision that's all i came up with... ok so i didn't know that the GDK version was different, but you can't string me up just cuz i was asking about a command that i didn't understand and it's unfair to assume that i'm not trying to learn... and by looking for that command doesn't it show that I'm trying to learn from other peopls code?

and for the record i tried your suggested line of coding already and still didn't get desired results.

Windows 7 64 bit, AMD Phenom II x4 Black edition, 4 GB Ram, Radeon HD 4650, 540 GB HDD

I can see from your smile, you're not here for the sunset.
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 30th Mar 2010 16:03 Edited at: 30th Mar 2010 16:12
Well I apologize if I was a little harsh. Maybe I was just a little grumpy then.

The command SC_sphereCast() only casts a sphere defined by the parameters into the collection of objects that are setup by SC_setupObject. Basically, that means that it doesn't matter what's at the start position of the sphere. There could be nothing at all. It only casts an arbitrary sphere.

I did make a mistake in the code I posted. It should be:

Regardless, the only reliable key to success is appropriate integration of the code. When you say you tried it and it didn't work, what did you try?

Edit: When I say that the command only casts an arbitrary sphere, I mean there's nothing camera-specific about SC_sphereCast(). For all the program cares, you could have an object, a camera, or nothing at all at (oldX,oldY,oldZ).

Edit 2: The line I posted WILL cast a sphere from (oldX,oldY,oldZ) to (camera position x(),camera position y(),camera position z()). The only thing left to do is figure out how to properly integrate it into your project. There should have been help files in your Sparky's download that explain how to do that.
Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 31st Mar 2010 01:28
This is making my brain hurt... no matter what i try i can't get it to work... I been reading the help files galore but i just can't understand it. /sigh

I've tried placing a speher at the camera location, i can get the sphere to move with the camera but it won't collide and when it does collide it doesn't move and i just can't get the sc_spherecast to work at all... i just fail at sparky's and it's frustrating me.

Windows 7 64 bit, AMD Phenom II x4 Black edition, 4 GB Ram, Radeon HD 4650, 540 GB HDD

I can see from your smile, you're not here for the sunset.
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 31st Mar 2010 01:56
Hey now, don't get too down on yourself.

Why don't you show us some code so we can push you in the right direction?
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 31st Mar 2010 17:39
Here is some code that should help you Levanthus:



use the arrow keys to move. Several boxes are used to create a 'world'. You move around the world and the camera collides with it. The boxes in this world are all placed into group 1, which Sparky's checks for.

I hope this helps.

LB

Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 31st Mar 2010 22:21
Thanks LB that code was really great, however when i try and implement it as a third person camera object it sort of sticks a bit and then goes through the wall anyway. I been staring at this thing and trying to make it work for almost 10 hours straight now and i'm getting nowhere so thanks for the help guys but i'll probably just shelf this idea and work on something i know i can do, i do appreciate the time it's taken you to answer this and i'm sorry if i'm getting annoying with asking and complaining all the time, but right now i'm just fed up and frustrated.

Windows 7 64 bit, AMD Phenom II x4 Black edition, 4 GB Ram, Radeon HD 4650, 540 GB HDD

I can see from your smile, you're not here for the sunset.
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 1st Apr 2010 10:48
Here, this might help. This is the code I wrote a while back to learn the ropes with Sparky's. It features sliding collision and third person camera collision. Most of this code was written based off the sliding collision demo that came with the DLL. The code should be pretty well commented.

Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 2nd Apr 2010 00:54
Thank you guys, you are legends, both of you. After examining your code I think I'm starting to understand. I'm sorry I went a bit off the rails, I was trying to learn from you but I guess I just got too tired after spending so long at it and failing. I really do appreciate all the effort you went through to help me, and now that I have the coding you have generously supplied, I have managed to adapt it to do exactly what it was that I was trying to do.

I really can't express how greatful I am thank you both SO much

Windows 7 64 bit, AMD Phenom II x4 Black edition, 4 GB Ram, Radeon HD 4650, 540 GB HDD

I can see from your smile, you're not here for the sunset.
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 3rd Apr 2010 03:19
You're welcome. I'm glad you got it working.

PS - Cool avatar

Login to post a reply

Server time is: 2024-04-18 23:45:13
Your offset time is: 2024-04-18 23:45:13