0

I experimented with my code to get the r object to not go through the land object or o. The object goes through all of it side up, down, back, right, left but the forward is the one that works. The problem is that the if collider loop only stop at the forward part. Is there something with the direction function like you can only use one. I also tried to do raycasting but I'm pretty sure that supposed to be only for player objects because when I try to use it on other entity objects it goes up and right. I tried thinking about other ideas but they involve using the directional function. So any of you have any ideas.

import ursina
from ursina import *
from ursina.prefabs.first_person_controller import FirstPersonController
import random
import time
import pygame 

app = Ursina()
EditorCamera()
cam = FirstPersonController(y=-2)
position = Vec3(0, 7, -3)
turnSpeed = 1
speed = 1
o = Entity(model='testing',texture_scale=(60, 60), texture='white_cube', scale=60, collider='mesh', position=Vec3(1,-1,60))
v = Entity(model='cube', color=color.orange, collider='box', origin = (0, -3, -3), parent = cam)
r = Entity(model='cube', color=color.gray, scale=2, collider='box', position=Vec3(0, 7, -3))




def input(key):
        if key == 'q' or key == 'escape':
            quit()
            exit()



def  update():

         v.z += (held_keys['w'] - held_keys['s']) * time.dt * 6
         v.x += (held_keys['d'] - held_keys['a']) * time.dt * 6
         r.x -= 1
         if r.intersects(o).hit:
             if r.forward:
                 r.z += 1
             elif r.back:
                 r.z -= 1
             elif r.right:
                 r.x -= 1
             elif r.left:
                 r.x += 1
             elif r.up:
                 r.y += 1
             elif r.down:
                 r.y -= 1

                 
         
app.run()
Terry Jan Reedy
  • 18,414
  • 3
  • 40
  • 52

0 Answers0