Giter Site home page Giter Site logo

Comments (9)

DiamondsBattle avatar DiamondsBattle commented on July 17, 2024

Add the collider='entity_model' to the Entity, wich will add to it a 'hitbox'.
my_entity = Entity(model='cube', collider='cube') # This will add the hitbox
For other questions, you should head on the Discord Server.

from ursina.

Karma428507 avatar Karma428507 commented on July 17, 2024

thank you

from ursina.

Karma428507 avatar Karma428507 commented on July 17, 2024

didn't work

from ursina.

DropBear586 avatar DropBear586 commented on July 17, 2024

Collision detection isn't straightforward unfortunately.
You need the "hitbox" or collider and a raycast. Think of it as a laser which you shoot in a direction for a specific distance and check if it returns a hit on a objects collider, if so, do something.
Check out the documentation of the webpage for some examples and keep an eye out on the discord as Im making a more simpler collider detection which involves coordinates rather than the collider and ray cast.

from ursina.

Karma428507 avatar Karma428507 commented on July 17, 2024

thank you

from ursina.

pokepetter avatar pokepetter commented on July 17, 2024

The first step is to add a collider. See here: https://www.ursinaengine.org/cheat_sheet.html#Collider
And then to raycast: https://www.ursinaengine.org/cheat_sheet.html#raycaster
The raycast will then return a HitInfo: https://www.ursinaengine.org/cheat_sheet.html#HitInfo

Here's how I do in in the FirstPersonController, in its update function:

self.direction = Vec3(
    self.forward * (held_keys['w'] - held_keys['s'])
    + self.right * (held_keys['d'] - held_keys['a'])
    ).normalized()

middle_ray = raycast(origin , self.direction, ignore=[self,], distance=.25, debug=False)

if not middle_ray.hit:
    self.position += self.direction * self.speed * time.dt

from ursina.

pokepetter avatar pokepetter commented on July 17, 2024

You can also use entity.intersects() to check if its collider intersect other colliders.

from ursina.

oyae avatar oyae commented on July 17, 2024

I have that problem, but with the "floor", the thing is that when I walk through a certain part of the floor, I fall over, I tried to solve this by reset player y= 1 when this happens, but it didn't work, I will appreciate any help

from ursina.

oyae avatar oyae commented on July 17, 2024

code.txt

from ursina.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.