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 / What am I doing wrong?

Author
Message
gormee
14
Years of Service
User Offline
Joined: 10th Oct 2010
Location:
Posted: 3rd Nov 2010 17:40
I have been trying to code a simple game and I've been having problems bounding the player box within a matrix. I have tried setting up some walls, turning on their collision and hiding them from view as a simple solution but my collision doesn't seem to work. When my player box collides with other objects it works fine, its just the boundary walls that seem to have a problem. What am I doing wrong?


I am also trying to get the camera to rotate along with the player box orientation, but it doesn't work very well. Anyone got any suggestions for me regarding that? Any help would be much appreciated.

Thanks!
29 games
19
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 3rd Nov 2010 23:53
Hi gormee.

I've had a look at your code and figured out that your boundary collision problem is due to the order in which you're doing things. Your current program goes:

1: save old coordinate
2: check collision (move object back to old coordinates if collision is true)
3: player moves object

The order should go:

1: save old coordinates
2: move object
3: check collions (move object back to old coordinates if collision is true)

I also noticed that your walls are too short (your matrix is 500 x 500 units and your walls are only 300 units long).

The camera following the object I believe is a bug so you need to save the object angle to a variable first and then use that in "set camera to follow" cammand.

I have updated your code below.



I've moved the three lines where you saved the old position of the box and the controls to the top of the main loop (line 59), made the walls longer and set a variable for the angle of the object to use in the "set camera to follow" command (line 145). I've also indented your code.

Hope this helps but I bet your next question is how to get the player object to slide against the wall
gormee
14
Years of Service
User Offline
Joined: 10th Oct 2010
Location:
Posted: 4th Nov 2010 12:08
Thanks for pointing out the error.. much appreciated! I'm not too fussed about sliding collision just yet, I'm actually more interested in getting the camera to work well first before worrying about other stuff.

I have tried the code that you have kindly written up for me, but the camera still behaves weird when i hold down the left or right keys for about 2 secs, the camera doesn't track the player box as it rotates to face the back, it just stays stationary and watches as the player box rotates on its pivot until it the box faces the front again.

Are there better camera solutions than the one I am trying to implement?
29 games
19
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 5th Nov 2010 00:45
Sorry about that, I didn't test the code thoroughly enough.

It's a very odd problem. It seems that the "object angle y()" command is not returning the correct angle of the object. If you look at the this example of a rotating cube:



It returns a value for the y angle between 90 and -90 (i.e. when the object rotates through say 95 degrees the "object angle y()" command returns a value of 85 degrees) even though the cube rotates through a full 360 degrees. Also, the object's x and z angles change from 0 to 180 degrees (when it has rotated through 90 degree). Maybe someone with a bit more knowledge than me could explain this, it's just odd to me (maybe there's some update I'm unaware of).

I think this was causing the problem not the "set camera to follow" command.

Anyway, I figured out a work around.

Rather than rotating the object directly, the left and right keys change a "facing#" variable and then the object is y rotated to this value (line 62) and I changed the "set camera to follow" command to use the "object angle y()" command (line 148)

X_MEN
21
Years of Service
User Offline
Joined: 14th Sep 2003
Location:
Posted: 5th Nov 2010 03:13
Try this hope it help







You can do it if you try
gormee
14
Years of Service
User Offline
Joined: 10th Oct 2010
Location:
Posted: 5th Nov 2010 06:11
Thnks 29 games.. your help has been most useful!

Xmen thnks for your solution too.. it works great and is exactly the kind of cam sys I've been looking for!

Now i can continue to refine my game.. much appreciated guys!!!
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 6th Nov 2010 01:25
@29 games... I'm not sure if this is correct, but I don't think the commands like turn object right work well with object angle y and rotate object because they use different rotation systems. I'm most likely totally wrong though.

Dia
19
Years of Service
User Offline
Joined: 16th Jan 2005
Location:
Posted: 6th Nov 2010 03:22
nah you are not wrong, coming to you live from the dbpro help files:

Quote: "Be aware that you cannot use EULER ANGLES in combination with this command. Euler angles are accessed with the ROTATE OBJECT command, whereas Freeflight commands are accessed with the TURN, PITCH and ROLL commands."


you get some wierd results mixing the two types of rotation, (some of the rotations default back to zero etc)

This is not the Sig you are looking for....
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 7th Nov 2010 12:26
They do work better than they have in the past with the latest release, but if you are expecting to get clean 0-360 degree values from the object angle commands, you'll be disappointed.

The values that you do get are correct, even though they may be unexpected. That's the problem when you work with Euler angles - there can be several different sets of angles that end up pointing your object in the same direction.

Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 12th Nov 2010 16:22
Ezrotate overcomes alot of the problems you face with rotation.

29 games
19
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 14th Nov 2010 23:54
Quote: "if you are expecting to get clean 0-360 degree values from the object angle commands, you'll be disappointed"


A little suprised more than disapointed as I can't remember ever using the GET OBJECT ANGLE commands before.

Thanks for the info.

Login to post a reply

Server time is: 2024-11-24 09:29:29
Your offset time is: 2024-11-24 09:29:29