Problème de Collision Ursina et Blender

OP
CR

CyberRaptor

il y a 3 mois

Bonjour,
Depuis 3 jours maintenant, je suis bloqué car j'ai concu un bout de programme :
import os
import sys
from ursina import *
from ursina.prefabs.first_person_controller import FirstPersonController
import random
import time

app = Ursina()

  1. Récupérer tous les fichiers de textures dans le dossier .oeuvres

textures = []
oeuvres_folder = 'oeuvre' # Dossier contenant les textures

if os.path.exists(oeuvres_folder):
for file_name in os.listdir(oeuvres_folder):
if file_name.endswith(('.png', '.jpg', '.jpeg')):
textures.append(file_name)
print(f"Liste des textures: {textures}")

  1. Liste de positions et orientations prédéfinies pour les tableaux

positions = [
((0.6, 3, -40), (0, 270, 0)), # (Position, Orientation)
((-0.6, 3, -40), (0, 90, 0)),
((0.6, 3, -60), (0, 270, 0)),
]

  1. Choisir un tableau aléatoire à trouver

tableau_a_trouver = random.choice(textures)
print(f"Trouvez le tableau: {tableau_a_trouver}")

def tableau_clique(i, tableau_a_trouver):
if textures[i] == tableau_a_trouver:
print("Bravo! Vous avez trouvé le tableau!")
else:
print("Désolé! Ce n'est pas le tableau à trouver!")

random.shuffle(textures)

  1. Chargement du modèle 3D avec collision

model = load_model("sans_nom.glb")
terrain = Entity(model=model, collider='box', scale=(1, 1, 1), position=(0, 0, 0)) # Collider de type 'box'
terrain.visible_bounds = True # Activer la visualisation du collider

  1. Créer plusieurs tableaux avec des textures choisies aléatoirement et à des positions et orientations prédéfinies

tableaux = []

for i in range(min(len(positions), len(textures))):
position, rotation = positions[i]
random_texture = textures[i]

tableau = Entity(
model='quad',
texture=os.path.join(oeuvres_folder, random_texture),
position=position,
rotation=rotation,
scale=(5, 3),
collider='box',
on_click=lambda i=i: tableau_clique(i, tableau_a_trouver)
)

hitbox = Entity(
model='cube',
color=color.red,
position=position,
scale=tableau.scale,
collider='box',
parent=tableau
)

tableaux.append(tableau)

window.cursor_enabled = True

  1. Ciel

sky = Sky()

  1. Joueur avec collider box et échelle spécifiée

joueur = FirstPersonController(collider='box', speed=10, position=(0, 2, 0)) # Position initiale ajustée
joueur.visible_bounds = True # Activer la visualisation du collider du joueur

  1. Texte affichant la position et l'orientation du joueur

position_text = Text(position=(-0.5, 0.45), scale=2, color=color.white)
orientation_text = Text(position=(-0.5, 0.4), scale=2)

def update():
position_text.text = f'Position: {joueur.position}'
orientation_text.text = f"Rotation: (X: {joueur.camera_pivot.rotation_x:.2f}, Y: {joueur.rotation_y:.2f})"

app.run()

Mais la, je fais face à un problème : je n'ai absolument aucune collision avec les murs.
Savez vous d'ou cela vient car je ne trouve rien sur internet, personne qui a eu ce problème ?
merci d'avance