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 / Cant solve this little problem :-(

Author
Message
silenus
15
Years of Service
User Offline
Joined: 4th Mar 2009
Location:
Posted: 11th Mar 2009 00:58
On the picture you can see my player. I wrote a function that shows me where the lower ground is. Marked by a cube.
With this code I calculate 8 positions around the player:

than I take the groundheight an sort it with this algorithm:

Quote: "min= y_temp[i];
min_pos=i;"

with min_pos I calculate my correction Angle, wich I use to move the Player to the lower ground:



But as you can see on the picture my lower ground is by 90° and not as my code says at 180°

Where is my mistake?
Does some one has a glue?
silenus
15
Years of Service
User Offline
Joined: 4th Mar 2009
Location:
Posted: 11th Mar 2009 01:00
where is the picture???
I hope this works:
http://img4.imageshack.us/my.php?image=testbild.jpg
sydbod
15
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 11th Mar 2009 03:07
Your first code snippet shows how you are creating the angles for the 8 directions around the player.

You have not shown people the code you are using to actually measure the height and at what distance from, with reference to the center axis of the player.

Sorry, but there is just not enough information for people to even guess at what is happening.
silenus
15
Years of Service
User Offline
Joined: 4th Mar 2009
Location:
Posted: 11th Mar 2009 11:47
Ok, here is the code for measuring:




But this code works fine. As you can see in the picture, the cube marks the lower and the cone the higher ground. This is always right.
Before I calculatet with y_temp[min_pos] the corrected position. That did it, but it wasn't nice to see when you tried to climp a very steep hill.So I decided not to calculate a new position but a value for movement correction.

And here I calculate the corrected value for movement:

void GravityPlayer()
{
float Forward_delta=0;
float Side_delta=0;
if (HeightDifference > 25)
{
correction = HeightDifference * 0.4;
Forward_delta = dbCOS(CorrectionAngle)*correction;
Side_delta = dbSIN(CorrectionAngle)*correction;
/*if the lower ground is ahead, the velocity in
forward direction is increased.Is the lower ground in the back,
player is forced to move back.*/
MovementForward = MovementForward - Forward_delta;
MovementSide = MovementSide + Side_delta;
dbText(150,20,"Korrekturwinkel" );
dbText(290,20,dbStr(CorrectionAngle));
}

Sometimes it works fine, but mostly the correction angle is wrong
When I use angle_temp[min_pos], I can calculate the corrected position. This works correct, but it looks stupid when you try to climp a steep hill upwards and you are be placed always back. Its very jerking. Thats why I want to correct the speed of dbMoveObject ( int iObject, float fSpeed )

I attached my map + objects and the main.ccp

@sydbod
thank you for having a look

Attachments

Login to view attachments
sydbod
15
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 11th Mar 2009 15:42
@ silenus,

A most interesting problem.

There are a few problems with the code that I can detect but not yet pinpoint.

When approaching a steep hill from one side, the player will slide DOWN the hill. When approaching from the other side of the hill, the player will slide UP the hill.

It looks like the trig functions are messed up some how, although I can not see clearly how at the moment.

It should just be a matter of displaying all the relevant variables on the screen when it is running, and seeing what the values are doing in real time.

I can not look at it properly for another 48 hours as I have another family commitment, but this problem has me very interested and I will look at it after that, unless you have already found the answers.

In "void GravityPlayer()" this change in value will make it easier to see what is going on with your gravity sliding.



I will get back to you
silenus
15
Years of Service
User Offline
Joined: 4th Mar 2009
Location:
Posted: 11th Mar 2009 16:00
Thank you again
When I've found the solution I'll present it here. But I try to get it for about 3 days now.
The idea with HeightDifference * 0.02; is great.
I 've added if (dbKeyState(57)) dbText(150,20,"hold" );
In the function GravityPlayer():

So I can place a Hold-Point there witch just breaks the programm when spacebar is pressed. Maybe I can find the error this way
sydbod
15
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 12th Mar 2009 07:23 Edited at: 12th Mar 2009 07:39
@ silenus,

It looks like your problems started when you made a wrong assumption about the loading of the "Colonel-x.X" model.

When it gets loaded into the game it is actually facing the wrong way round. Its front is facing to where its back should be.
this is why you are using negative numbers to move the model forward and likewise the left/right/backwards movement numbers are also all of the wrong polarity.

You will have to correct the model as follows.




It looks like you have also gotten your X and Y mouse axis mixed up when you are calculating for the rotation around the X and Y rotation axis of the player model.


I also created a set of colored balls in the "DarkGDK( )" function


And located them where each of the feel locations should be situated.
In the "IsGroundSteep()" function we added the balls.


With those balls in place one can see the feeler locations rotating much faster than the player is rotated.
This suggests that somewhere you have used a value in Degrees when a function probably wanted a value in Radians.
EDIT: Things like "x_delta = sin(angle_temp[i])*Hyp;".
The "sin(RADIANS)" function requires Radian values, and you are passing into it Degree values.

As I said, I will look at it tomorrow when I again have a bit of time, and maybe rewrite it a little to make it a bit clearer to read.
At least it gives you something more to think about in your code.
silenus
15
Years of Service
User Offline
Joined: 4th Mar 2009
Location:
Posted: 12th Mar 2009 10:37
Thank you again
That the model is facing the wrong side I discovered yesterday too, but I thought this does not explain why I can climb a from one side and not from the other.
Here is the screenshot:

http://img27.imageshack.us/my.php?image=74411638.jpg
As you can see at the picture, cube and cone at the right position.
And the next pictures shows what the code does:

http://img27.imageshack.us/my.php?image=91513682.jpg

http://img27.imageshack.us/my.php?image=13646613.jpg

The thing with radiant and degree I was told before, thats why I used dbSIN and dbCOS for:
Forward_delta = dbCOS(CorrectionAngle)*correction;
Side_delta = dbSIN(CorrectionAngle)*correction;
But I've forgotten to change it in IsGroundSteep().
I will now add your code and hope for the best
And another thing I found out. I don't need 360° because 0° and 360° are the same.
I ll try it now and give you feedback on the spot.
silenus
15
Years of Service
User Offline
Joined: 4th Mar 2009
Location:
Posted: 12th Mar 2009 12:01
Much better now!!!

I added:
dbLoadObject ("Colonel-x.X",3);
//dbYRotateObject ( 3, 180.0 );
dbFixObjectPivot ( 3 );
When I rotate the Object by 180° I always have to look at the ugly face of the Colonel, so I decided to watch his back

The CorrectionAngle is now calculated this way:

CorrectionAngle = min_pos*45 + 180;
if (CorrectionAngle>360)
CorrectionAngle = -dbWrapValue(CorrectionAngle);

Forward- and backward movement now works fine, just sidewards is not perfect.

I thought it would never be working, but because of you its almost done, thank you again !!!

the actual main.cpp is attached.

Attachments

Login to view attachments
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 12th Mar 2009 12:23
If you look in the sample code at Dark dungeon, camera and image showcase, plus a few others with charters in them it would have show you how to set them up.

Dark Physics makes any hot drink go cold.
silenus
15
Years of Service
User Offline
Joined: 4th Mar 2009
Location:
Posted: 12th Mar 2009 14:28
@HowDo
camera is not the problem. The Problem is to make the player slide down on steep ground at the right direction. And in Dark Dungeon there is no steep ground...
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 12th Mar 2009 14:40
Oops, I thought I put in there information on character positioning, which is what I was on about.

Dark Physics makes any hot drink go cold.
silenus
15
Years of Service
User Offline
Joined: 4th Mar 2009
Location:
Posted: 12th Mar 2009 14:44
no problem
sydbod
15
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 12th Mar 2009 15:10
@ silenus,

It is important to make sure everything is working the correct way around .... otherwise it becomes very hard to visualise what the trig functions are doing to the data.

Let us fix the direction properly.




And so that we again will be looking at the back of the player model.



After these changes, one is now ready to tackle the sideways sliding code that is not working properly yet.

It is well after midnight here so I am back into bed and will look at this last problem in the morning when I wake up again .... unless you have already sorted it out.
I think that should be the last problem.
silenus
15
Years of Service
User Offline
Joined: 4th Mar 2009
Location:
Posted: 12th Mar 2009 15:17
Nice, I try it this evening, because I have to go to work now
sydbod
15
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 12th Mar 2009 15:57
This should be the last FIX required



Now the character slides down hill from all directions.

It was fun to play with your code
silenus
15
Years of Service
User Offline
Joined: 4th Mar 2009
Location:
Posted: 12th Mar 2009 22:20
Quote: "It was fun to play with your code"


Now it is our code. Without you I couldn't have fix this
Thank you man!!!
silenus
15
Years of Service
User Offline
Joined: 4th Mar 2009
Location:
Posted: 13th Mar 2009 01:47
Hi sydbod,
I ve done a little more. Now one can jump. Still not perfect, but I know how to fix this. But now its is for me time to go sleep
I ve marked the new stuff with "//<---------New"
sydbod
15
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 13th Mar 2009 11:52
Good stuff,

It becomes very addictive.
Keep going with it and see how far you can develop it to.
Maybe further down the line you may want to play with some of the many Physics libraries that are available. Then things become very interesting with all the new posibilities.
It was great to see a person trying to do more complex operations by mathematics, rather than just integrate additional libraries into their code.
silenus
15
Years of Service
User Offline
Joined: 4th Mar 2009
Location:
Posted: 13th Mar 2009 12:09
Quote: "you may want to play with some of the many Physics libraries that are available."

I've downloaded Nvidia PhysX and Newton SDK. But my C++ knowlege is not enough to use these things. So I was forced to do it by my own
silenus
15
Years of Service
User Offline
Joined: 4th Mar 2009
Location:
Posted: 14th Mar 2009 01:51
Now I finished jumping. Still not perfect but it works.
@Sydbod and all the others
Do you think this code is good enough to post it in
<code snippets> ?

sydbod
15
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 14th Mar 2009 14:24
@ silenus,

It is not a case of if the code is good enough .... it is a case of if the idea is good enough to be of interest to others.

Your approach to a simple means of creating a terrain steepness climbing limit with a sort of a gravity slippage effect is something well worth while to include to the code snippets area.

I am sure others will find it interesting and probably useful somewhere.

Login to post a reply

Server time is: 2024-05-17 07:29:18
Your offset time is: 2024-05-17 07:29:18