Just some questions

All topics about ZGameEditor goes here.

Moderator: Moderators

jinxtengu
Posts: 124
Joined: Wed Oct 14, 2009 2:05 pm
Contact:

Just some questions

Post by jinxtengu »

hello, I've been getting into z game editor lately and I was wondering
if I could get a few questions answered. I apologize if they seem simple.

first thing that comes to mind:

when rendering variables as text onto the screen for debug purposes how
do I display decimals? it always goes to whole numbers.
I haven't quite been able to work this out, what I've been doing to overcome this problem is using the float multiply to multiply the variable by say 100 and then imagining a decimal point. but this doesn't fix the problem.

-------
where can i find the complete list of character code equivalents? it took me ages of trial and error to discover that 32=space bar.
this should be written in the help file.

-------
how should i program collision detection with an un-uniform terrain?
to be used for example for walking over hills.
should this be done using many round 3d collision detection zones..
ok this isn't a great question it's just i have been having some difficulty
in having collision detection with objects other than cubes.
---------
how big can you make games with z game editor?
what are the limitations?
I wouldn't want to spend a year on a game and find that it doesn't work
due to size limitations inherent within the program.
I mean it says in the read me it's only for simple games.
--------

when I play a midi tune during running of a game using the music control component
not all the channels play even though they work when tested within the editor. why might this be happening?

-------
what things need to be multiplied by delta time?
is it only objects that use gravity and physics, or should I multiply
variables by delta time, for example loops that determine enemy movement and ai.

--------------

whats the easiest way to synchronize a models direction with it's movement on the z and x axis? not including the use of steering behaviors. I have been finding this a difficult problem to solve.
I wrote a code which seemed to work however after the model rotated say 60 times the direction it faced became out of sync with the direction it moved.

any help and suggestions would be much appreciated
User avatar
y offs et
Posts: 418
Joined: Wed Apr 22, 2009 4:26 pm
Location: BC, Canada

Post by y offs et »

"great expectations"
jinxtengu
Posts: 124
Joined: Wed Oct 14, 2009 2:05 pm
Contact:

Post by jinxtengu »

thanks, that solves my second question.
I did not realize the codes were ascii.
User avatar
Kjell
Posts: 1924
Joined: Sat Feb 23, 2008 11:15 pm

Re: Just some questions

Post by Kjell »

Hi jinxtengu,
jinxtengu wrote:when rendering variables as text onto the screen for debug purposes how do I display decimals? it always goes to whole numbers.
A floatToString function is currently not build-in ZGE, but you can add it to your project using a ZLibrary yourself. Check this thread and / or the attached example.
jinxtengu wrote:where can i find the complete list of character code equivalents?
The link y_offs_et provided is a good resource. Also, keep in mind that you can enter key(s) as string in the Keys property of a KeyPress component. So for example, "S" in Keys is the same as CharCode "83".

Image
jinxtengu wrote:how should i program collision detection with an un-uniform terrain?
This entirely depends on your terrain. I suspect you want to use a so-called "polygon-soup", in which case you probably have to think about spatial indexing strategy ( depending on your polycount ). If you would provide some more details I could give a more detailed suggestion :wink:
jinxtengu wrote:how big can you make games with z game editor?
The only "limitation" I've encountered is that saving your project file can get quite slow when you reach the 100MB+ regions. So, if your project is using allot of imported assets like bitmaps / sounds / meshes, you might want to consider using external files and loading them using the File component.
jinxtengu wrote:when I play a midi tune during running of a game using the music control component
not all the channels play even though they work when tested within the editor.
No idea ( I never use the Music component ), sorry.
jinxtengu wrote:what things need to be multiplied by delta time?
Anything that is time based. Keep in mind that the Velocity properties are automatically multiplied by delta-time.
jinxtengu wrote:whats the easiest way to synchronize a models direction with it's movement on the z and x axis?
You can get the direction / angle based on the movement vector using atan2(Y,X) .. although personally I usually go the other way around, and base the movement on the angle instead :)

Don't hold back in case you've got any more questions ~

K
Attachments
Float.zgeproj
(3.82 KiB) Downloaded 671 times
User avatar
VilleK
Site Admin
Posts: 2371
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Hi and welcome jinxtengu,

Kjells answers are correct as usual, I just want to add that if you have problems with a specific midi-file you can post it here and let me try it out. As an alternative to midi-files is to play music using an external dll, see ModPlay that is one of the sample projects with ZGE.
jinxtengu
Posts: 124
Joined: Wed Oct 14, 2009 2:05 pm
Contact:

Re: Just some questions

Post by jinxtengu »

Thanks to everyone for answering my questions.
The answers have been very helpful to me.

i have a couple more questions

----------------------------
should z expressions be run under the on-render condition or under the on-update condition and does it matter?
-----------------------
is there an easy way to set all variables to one number?
this would be useful for changing app states because I sometimes notice that variables
not reset to 0 produce odd effects when a game cycles through app states.
--------------------------
under the properties box of a model,
under the collision bounds category there are 4 values,
I’m assuming the first 3 are x,y,and z coordinates so what’s the fourth one for?
--------------------------------------

Kjell wrote:how should i program collision detection with an un-uniform terrain?

This entirely depends on your terrain. I suspect you want to use a so-called "polygon-soup", in which case you probably have to think about spatial indexing strategy ( depending on your polycount ). If you would provide some more details I could give a more detailed suggestion
I don't know about "spatial indexing strategy"

I’ve been designing a game with islands sitting in an ocean and I was wondering how I should do
the collision detection with the islands, so that as you climb a hill on an island the players Y coordinate
follows the curve of the hillside.

the island that I’ve been testing is just a mesh grid with a protuberance in the middle.
I’m thinking perhaps the way I’ll go about it will be to build a pyramid of closely spaced
cubes and disguising it as a rounded hill.

another thing that I’ve noticed is that the collision detection with 3d cubes doesn’t appear to be accurate if the cubes are spawned at an angle. it seems that the collision detection doesn’t factor in the rotation of the model.
User avatar
Kjell
Posts: 1924
Joined: Sat Feb 23, 2008 11:15 pm

Re: Just some questions

Post by Kjell »

Hi jinxtengu,
jinxtengu wrote:should z expressions be run under the on-render condition or under the on-update condition and does it matter?
In general you want your expressions to be in OnUpdate. That way you can be sure they are executed before the actual rendering starts.
jinxtengu wrote:is there an easy way to set all variables to one number?
Not really. The most common solution is to put a ZExpression in OnLoad / OnStart that resets all variables that might have been altered. Also, if you want to for example set the App.CameraPosition values ( X / Y / Z ) to 0, you can simply use "App.CameraPosition = 0;".
jinxtengu wrote:under the properties box of a model, under the collision bounds category there are 4 values, I’m assuming the first 3 are x,y,and z coordinates so what’s the fourth one for?
None of the collision styles actually uses the 4th value, so no idea why it's there to begin with :P Some collision styles actually only use the first or first two values. Quoted from the documentation ..
CollisionBounds
The size of this model when it is tested for collision. This value is interpreted differently depending on the value of the CollisionStyle-property:
  • CollisionStyle is Rect2D or Rect2D_OBB: The first value represents the width, and the second value is the height.
  • CollisionStyle is Sphere3D or Circle2D: The first value is the radius of the sphere.
  • CollisionStyle is Box3D: The first value represents the width, the second is height, and the third value is the depth (x,y,z).
Try enabling the "Bounds" option to see what your collision shape actually looks like.

Image
jinxtengu wrote:I’ve been designing a game with islands sitting in an ocean and I was wondering how I should do the collision detection with the islands, so that as you climb a hill on an island the players Y coordinate follows the curve of the hillside.
You might want to consider going with a constant grid / height-map for each island. It's the easiest solution by far .. let me know if you need help with this.
jinxtengu wrote:another thing that I’ve noticed is that the collision detection with 3d cubes doesn’t appear to be accurate if the cubes are spawned at an angle. it seems that the collision detection doesn’t factor in the rotation of the model.
Correct. Only the Rect2D_OBB collision style takes Rotation ( the Z-axis ) in account. All other styles cannot be rotated.

ZGE's build-in collision capabilities are currently quite sparse. It's fine for Duck Hunt or Space Invaders, but if you want something a little more modern, you either want to use a Physics dll or write some functions yourself :wink:

K
jinxtengu
Posts: 124
Joined: Wed Oct 14, 2009 2:05 pm
Contact:

Post by jinxtengu »

Thanks for the answers!



Iv'e got another question.

I tried using the arctangent function for rotation and
found that the following code almost provides the desired effect.

Code: Select all

CurrentModel.rotation.y=atan2(currentmodel.velocity.x,currentmodel.velocity.z)/6.45;

the only problem is when the model rotates 360 degrees there is a slight jitter. I suspect
this is because the number atan is divided by is slightly off the ideal value. can anyone tell me
what number i should divide it by?
User avatar
Kjell
Posts: 1924
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

:)

Divide by PI*2. So in your case ..

Code: Select all

CurrentModel.Rotation.Y = atan2(Currentmodel.Velocity.X,Currentmodel.Velocity.Z) / (PI*2);
K
jinxtengu
Posts: 124
Joined: Wed Oct 14, 2009 2:05 pm
Contact:

Post by jinxtengu »

that works perfectly, Thank you Kjell.



How should I go about positioning a model so that it is relative to another
models direction but so that it is always slightly in-front of the other model?
not including the use of render transform.

what I'm trying to do is a screen fade in/out transition for a first person type game
which places a full screen model over the players view when the transition is required.

Alternatively, if there are any codes which could be used to modify the monitors rgb values
I would use that instead but I haven't found any and the example project z blast also uses a full screen model for transitions, so I’m assuming that that is the best way to go about it.

sorry if I ask so many relatively simple questions.
User avatar
Kjell
Posts: 1924
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi,
jinxtengu wrote:what I'm trying to do is a screen fade in/out transition for a first person type game
The standard way of doing this ( in game development ) is to switch to the default projection and render a quad. Now, you can't replicate this exact solution at the moment ( I'll harass Ville about this ) without using OpenGL / Shaders, but there are a whole slew of alternatives available. The attached example has a inverted box using a Material with Z-Buffer turned off placed around the camera. Not the ideal approach, but it works just fine 8)
sorry if I ask so many relatively simple questions.
Keep em coming ~

K
Attachments
Fade.zgeproj
(2.05 KiB) Downloaded 683 times
jinxtengu
Posts: 124
Joined: Wed Oct 14, 2009 2:05 pm
Contact:

Post by jinxtengu »

thanks for explaining that.

although I still don't understand how to have an offset relative to z and x angle.
User avatar
Kjell
Posts: 1924
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hmm,

Can you explain what you're trying to do? I thought your "How should I go about positioning a model so that it is relative to another models direction" question was related to doing a fade effect, but apparently not? :)

K
jinxtengu
Posts: 124
Joined: Wed Oct 14, 2009 2:05 pm
Contact:

Post by jinxtengu »

Kjell wrote:Hmm,

Can you explain what you're trying to do? I thought your "How should I go about positioning a model so that it is relative to another models direction" question was related to doing a fade effect, but apparently not? :)

K
it was related to that, but it's also a separate issue. I'll need to understand it for other things.

I'm trying to work out how to have a model relative to another models position but set slightly in-front relative to the direction that the model is facing.

for example say that I have a model of a fish and I want a red ball model to be always at the front of the fish.
I could get this to work by using render transform, although to my knowledge that would make the mesh ball just a part of the same model, which would mean that it wouldn't be able to execute it's own code.

does that make any more sense?
User avatar
Kjell
Posts: 1924
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi jinxtengu,

Yea, I know what you're referring to. It's just that sometimes there are tricks / easy-solutions for specific situations .. that's why I asked what you're trying to do.

Anyway, setting a Model relative to another isn't build-in at the moment. However, the "obstacle" that prevented that from happening has been solved a while ago :wink: In the meantime, you can use the function* used in the attached example ( scaling is ignored, let me know if you do need this ).

*There's actually a faster calculation to do this, but I have to look it up :oops:

K
Attachments
Relative.zgeproj
(1.53 KiB) Downloaded 678 times
Post Reply