Pack of problems

Hi Guys,
i am new in this forum and program already since 6 months with panda3d.
English is not my first language, please sorry for that.
I am a blind programmer and use python for my project.
Here, i have 3 problems, i hope you can and want to help me…

I write momentanly a 3d platformer as Audiogame and i have here 3 problems:

  1. The floor will be different materials, this are different sounds, but i don’t know, how i can do that with a inclined platform… for normal platforms, it is done…
    I use a 3d array, generated by a list-comprehention.
    And i have write functions, to fill in a value in a specify area between to points.
    For example:
    Point 1: 0, 0, 0
    point 2: 5, 5, 0
    then it will generate a sqared platform.
    Have you a solution for a inclined platform? I can calculate the cordinatepoints, but fill in in a 3d array is the problem…
    I can’t use numpy, because i need strings… that is my problem…

  2. How i can set this platformes as a floor? i have not fully anderstunded this collision type…

  3. How I can safe the maps in a good way? for the moment i use json whit a class safe function…
    Exsist a better way?

Ok, i hope you can help me…

Greetings
Christopher

Hi, welcome to the forums!

  1. I’m having some difficulty understanding what you mean. Could you explain more about your structure? Do you use some sort of 3D grid and place platforms between grid points, or do you build your world from square blocks?

  2. The common way to do collision detection against a floor is by using a CollisionRay pointing down from the player, and having a collision handler such a CollisionHandlerFloor or CollisionHandlerGravity to respond to this. Another approach is to use a CollisionHandlerQueue to check for the Z value of the first point of the ground collision and place the character there. This is demonstrated in the Roaming Ralph sample program.

  3. Your approach for saving to JSON sounds sensible. It’s simple and easy. You can also choose to use the writeBamFile function to save your generated geometry out in Panda’s BAM format. This will make it faster to load, but this will only store the information that’s in the Panda scene graph, and not the information you used to generate the map.

Hi!

Ok, thank you for your help.

I use a list comprehition, and the grounds are known as strings. Because the function tath play the foot steep sounds, checks, which ground on the cordinate is and play the right sound.
I post now the code for the insert of the platform… I have a mapbuilder, how can build a map… Maybe you can read the code and can beter anderstund how the code works…

def set_value(list_, start, end, val):
  '''set a value in a 3d list in a given area  

@list_ list, in which the value are to set
@start und @end two points, which are  inclined 
@val the value to set
'''
  ranges = (range(*sorted(cord)) for cord in zip(start, end))
  for x in ranges[0]:
    list_x = list_[x]
    for y in ranges[1]:
      list_y = list_x[y]
      for z in ranges[2]:
        list_y[z] = val

def copy3dlist(seq, list_, start, end):
  ranges = (range(*sorted(cord)) for cord in zip(start, end))
  for i,x in enumerate(ranges[0]):
    list_x = list_[x]
    seq_i = seq[i]
    for j, y in enumerate(ranges[1]):
      list_y = list_x[y]
      seq_j = seq_i[j]
      for k, z in enumerate(ranges[2]):
        list_y[z] = seq_j[k]

this generate a block, yes… but this methode is not very good…
i hope you can help me in this problem…
where can i find the file function that you have wrote in your post?

Hmm, I’m starting to understand a bit more. If I understand correctly, you have a three-dimensional list containing the type of ground at a particular X, Y, Z coordinate, and the ground type is stored as a string in this list. Is this correct? This is effectively a voxel structure you have created, if I understand correctly.

So, is your question about filling in your arrays to set values along an inclined plane instead of a box? If so, you could do this by looping over the X and Y coordinates in the desired range, and then calculating the corresponding Z coordinate of the incline using some function of X and/or Y. For example, if you wanted the incline to go up one Z unit for every two Y units, you could determine the Z coordinate using Z = startZ + (Y - startY) / 2 .

As for writeBamFile, it is a method on the NodePath class. However, it will only store Panda nodes, and not arrays, so it won’t be useful for storing maps in the way you have presented - I may simply have misunderstood the way you generate maps.

Hi!
yeah, that is it!
ok, i hope i have anderstund you correctly.
And now a question for this planes.
When i walk whit the player on it, do panda3d automaticly, that the player change the z cordinate or it is so, that the player bounce in the next higher floor object?
When we image a stair…
the player stay on 0, 0, 0
and he go left, there is the stair…
then i want that he go automaticly go a z cordinate higher…
I don’t want, that the player bounce in the model of the next floor on 0, 1, 1

i hope you anderstund me…

the map saving, i want, that i have a platform name, for example “platform1” and then a cordinate array, where this platform, only the platform presentet.
When i load the map, i ask me the question, it is better to save all cordinates, the hull map whit air and so on?
or it is better, my favorit way, all platform has an extra array saved and the program will insert the platform array on the right place in the hull world array…
I hope, you can me help whit this many questions, because i don’t now, how quick panda3d here is…

ok, but thank you very much!

Okay, if I understand correctly, you want to smoothly transition to the higher level rather than popping up.

How to best do this depends on a lot of things. How big are the cells in your data structure - is each Z unit just a small step up, or a meter, or even an entire floor? How do you move around - do you move around one cell at a time, or do you want to walk freely within a cell?

If you want to walk around freely on these platforms, and have Panda3D handle the collisions, you would probably create a collision solid (such as a CollisionPolygon) for each grid cell, and use a CollisionRay pointing down to handle the collisions. It’s common to put the ray slightly above the character so that the character can move up stairs. If you want to smoothly handle inclined planes with this rather than stepwise, then you’d have to create the CollisionPolygon shapes at an incline.

If you want to create an tilted CollisionPolygon from the structure you use, you would have to check neighbouring cells to see if there is an incline. I’m not entirely sure that your structure is best suited for this. But I’m not confident that I fully understand what you’re trying to do to give you good advice.

Hi!
i haven’t anderstund this fully…
I want to go one zell by step.
the z-zells are 1 meter.
i want, that the charakter go this incline. platformes up or down, but i don’t want, that he crash in the next higher floor object…
i know, it is difficult, because i can’t speak so good english, that i can speak free…
and this whit the check the next zells, this are possible… but i tought it gives a better way…

what is whit the loading?
the x and y are only 10 centimeters, because we thought this is better for calculations for example projectil intervals and so on…