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.

Dark GDK / I need a Simple code for Sparky's collision

Author
Message
yahya
16
Years of Service
User Offline
Joined: 16th Oct 2008
Location:
Posted: 31st Mar 2009 02:06
OK I been trying to get my 3D character(.x) to stop going through the "universe.dbo", but he always goes through.

I was able to make a 2 shapes (Square and triangle for example), to do a collision with one another, it works, but when I replace the square with my .x character, he goes through the triangle :S.

Can I get a simple code that stops 3D characters(ex:ColonelX.x) going through the universe.dbo.
CheatCat
17
Years of Service
User Offline
Joined: 7th Mar 2007
Location: Sweden
Posted: 2nd Apr 2009 10:36
I think it is a bug.. It same thing for me, I can use collision with built-in objects, but not on loaded object. Or sometimes I can collide with loaded objects if I don't resize them. I have the latest (?) version of Sparky's.
yahya
16
Years of Service
User Offline
Joined: 16th Oct 2008
Location:
Posted: 4th Apr 2009 12:11
As I can see am not the only one having trouble with this , can someone plz help.
lego666
15
Years of Service
User Offline
Joined: 2nd Apr 2009
Location:
Posted: 5th Apr 2009 15:25
i'm beginner but i can help, try to attach a rectangle to your character or any object, and use the collision with the rectangle, ex: if rectangle collide with universe stop character.x and rectange.... hope it can help

BrainMech
Tiborko
16
Years of Service
User Offline
Joined: 25th Jul 2008
Location: In front of computer
Posted: 14th Jun 2009 22:10
That is very smart solution

Repetitio est mater studiorum!
yahya
16
Years of Service
User Offline
Joined: 16th Oct 2008
Location:
Posted: 15th Jun 2009 02:51
Ya but I kinda need him to go up the and down, not stop when colliding
yahya
16
Years of Service
User Offline
Joined: 16th Oct 2008
Location:
Posted: 16th Jun 2009 09:58
ummmm any help in this, its like the one of only things left I need which I'm really having problems solving :?

I need to finish this cursed game T_T
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 16th Jun 2009 11:08
Someone else had some trouble with collision and I posted some code in their thread, should only be a couple behind this one.

yahya
16
Years of Service
User Offline
Joined: 16th Oct 2008
Location:
Posted: 20th Jun 2009 17:10
Ok I think I got the idea form a friend how to do it, I just need to ask.


If I want the character to never stand in the air, what should I do ??
yahya
16
Years of Service
User Offline
Joined: 16th Oct 2008
Location:
Posted: 22nd Jun 2009 01:12
So like no one has ever had this problem before and solved it oO?
AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 22nd Jun 2009 03:23
Quote: "So like no one has ever had this problem before and solved it oO? "


Every problem is different. You have also provided us with none of your code, so what are we suppose to do? Write it all for you?

Sparkys collision works perfectly fine, when used correctly.

yahya
16
Years of Service
User Offline
Joined: 16th Oct 2008
Location:
Posted: 22nd Jun 2009 04:23
What are you talking about, I don't have anything wrong with my code, I just need the 3D character to go up a stairs and back down, and I need a way(in C++ code) to do this.

Am using a rotated square as a staircase:

example:
Quote: "dbMakeObjectBox(192,600,150,-50);
dbPositionObject(192,2100,530,-1465);
dbRotateObject(192,40,0,0);
SC_SetupObject(192,0,2);"


Now that I created a rotated square, I want the character when colliding from the bottom or the top of the object to be bale to walk freely on it, without anything pushing him up, down or him going trough it.

I was only able to make the character go up, but when I go back down, he doesn't go down the stairs but walks on the air :S.

So all am asking is for a souton for this, thats all.
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 22nd Jun 2009 13:12
IF sparky's is having trouble with your object and its scaled, try using :

SC_SetupComplexObject(ObjNum);
SC_AllowObjectScaling(ObjNum);

... here is a snippet of some working collision code, not sure if it will help you :



All you need to compile the above code is a .DBO file called "Terrain.dbo" - or u could rename that comand to "universe.dbo" if thats is your terrain.

It is the sliding demo from sparky's, it will load the object and setup a sphere for the "player" and show collision against it...

If it ain't broke.... DONT FIX IT !!!
yahya
16
Years of Service
User Offline
Joined: 16th Oct 2008
Location:
Posted: 23rd Jun 2009 15:38
^^ thanks Mista Wilson, everything works fine.


But one last thing, when I replace the sphere with my 3D object, the character keeps looking at the camera, so I changed it to:



I made the camera move with the mouse directions, but the camera keeps rotating upside down and keeps changing its angles when I move the mouse.

I want the Camera to move just like a FPS view mode, this is like the last thing I need
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 24th Jun 2009 01:20
The search button works wonders! like do "3rd person view" "camera control" something like that & you will find code to do what you want

yahya
16
Years of Service
User Offline
Joined: 16th Oct 2008
Location:
Posted: 24th Jun 2009 02:13
Will I did, after taking out the :




and



from the void positionCameraToObject( int obj, int thirdPerson), the Camera was moving normally with the mouse, but now the 3D character doesn't rotate :S(so close), I searched the baords, but so far everyone uses the same code:

or something similar, this makes the 3D character rotate, but alos stops the Cameras from rotating or sometimes it loops around the characters.

I'll keep sreaching, but if anyone can help me out it would save me a lot of tie, tyring 100 things out :S.
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 24th Jun 2009 04:22
Just adjust your objects YRotation by 180 degrees if its looking at the camera, no need to change the control code....(provided that its Y axis is UP, otherwise rotate whichever one IS up lol, also may want to dbFixObjectPivot() after rotating it...

dbYRotateObject(objCharacter , 180.0);

If you are positioning your camera to your character object, the movement of that object will also affect your camera movement, as i said, IF it is positioned to the object(using the above code's function for example)

The reason it would "flip around" would be that the camera is getting instruction to position itself to the model, and then to reposition itself according to mouse movement aswell....

You need to isolate it, so that, either the camera movement will move the character AND the camera will move itself to reposition OR move the camera, and the characeter will reposition.

You mentioned that you wanted a "FPS" style camera :

Press "V" while the original code I posted above is running and it will switch to "First Person Shooter" mode camera...

if you leave the code alone, and simply run it, it has a hotkey to change from third-first person perspective..... the "sphere" that is your character in that code, would probably be a camera collision item that it hidden during a real game. It works like normal FPS camera movement.... mouse= look around, WSAD = move..

ALL of the movement code for player movement is in the movePlayer() method... you really shouldnt need to comment out other methods..

If it ain't broke.... DONT FIX IT !!!
yahya
16
Years of Service
User Offline
Joined: 16th Oct 2008
Location:
Posted: 24th Jun 2009 11:41
naah, didn't work, I tried the approve code:


and



it ends up making the characters flicking 180 rotation all the time.


Quote: "You need to isolate it, so that, either the camera movement will move the character AND the camera will move itself to reposition OR move the camera, and the characeter will reposition."


Ya I already tried that, so one of them to move with the mouse movements and the other to fallow(ex:object-->MouseMovement, camera--->object), but it didn't work, it only makes the character rotate.

I just want a FPS view where I can move the mouse to look around(just like a FPS whereI can look up,down ot a cretin extent), on the same time the 3D character to rotate with the view.

Should I try to add a 2nd Camera?
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 25th Jun 2009 03:19 Edited at: 25th Jun 2009 03:22
no a second canmera wont work..... I really cant figure out what you've done lol

The original code that I posted, has a camera control that works exactly the way you are wanting it too....

The camera control is imbeded inside the collision routine, where you have the function above void movePlayer(); will only move the camera around the object, it wont move the camera forward or anythnig, it it essentially the "look around" part of the FPS controls..... the moving around part is controlled by the part of the movePlayer() method in my code above that has :



that accepts the input to move the character with WSAD keys(those numbers after the dbKeyState are keyboard scancodes numbers for the WSAD keys.


is the line that actually moves the player object..

Perhaps starting again, in a new project with just the code that I provided above, will allow you to see how it is meant to work...

Try changing some of the variables increment values, so they are going up or down quicker or slower and see how it affects your contols..... then you will get a sense of what is doing what in the code

[EDIT] : Also if you can, have a look through the Docs that come with GDK.... Start Menu->The Game Creators->DarkGDK->Documentation... to check what the commands are for before you change them...

If it ain't broke.... DONT FIX IT !!!
yahya
16
Years of Service
User Offline
Joined: 16th Oct 2008
Location:
Posted: 25th Jun 2009 15:34 Edited at: 25th Jun 2009 15:35
I friend of mine gave me a idea, and it worked, since I can't make 2 things fallow the MouseMovement,so:


int RotateX = dbMouseMoveX();
int RotateY = dbMouseMoveY();
positionCameraToObject( 50, view,RotateX,RotateY );

movePlayer(RotateX,-RotateY);

then go to the "positionCameraToObject" :

void positionCameraToObject( int obj, int thirdPerson,int RotateX,int RotateY)
{
float fCameraAngleX = 0.0f;
float fCameraAngleY = 0.0f;
dbPositionCamera( dbObjectPositionX(50)-10,dbObjectPositionY(50)+60,dbObjectPositionZ(50)+10 );
dbYRotateCamera( dbCameraAngleY() + ( RotateX/10.0f ) );
dbXRotateCamera( dbCameraAngleX() + ( RotateY/10.0f ) );
dbPositionMouse( 350,250 );
}


And it works , the character and Camera are moving together, now am trying to limit his rotation so they don't rotate a full 360 rotation :S, but everything works now, thanks for the help Mista, you really helped me out.

Login to post a reply

Server time is: 2024-11-25 08:38:14
Your offset time is: 2024-11-25 08:38:14