kennardconsulting / aframe-reset-on-collision

A-Frame component to prevent entities moving through walls
http://blog.kennardconsulting.com/2017/02/virtual-reality-art-show.html
5 stars 5 forks source link

Not a issue with your code but a issue with me #1

Open Therealjosephchrzempiec opened 3 years ago

Therealjosephchrzempiec commented 3 years ago

Hello I'm not very good with coding but there is my problem. I have a track for a game I'm working on. I'm trying not to go off the track. I searched online and trying to find a way not to go through walls or off track. I found your github page. Would this help me and do you have a example i can take a look at please? I tried your code but I got a little confused trying to set it up with my aframe.

Joseph

kennardconsulting commented 3 years ago

Hi there. I'm afraid my code probably won't be very good for a racing game. It uses AABB collision, which means all the walls have to be either 0, 90, 180, or 270 degrees. You can't have any 'diagonal' walls. So it's good for a maze game, for example.

Therealjosephchrzempiec commented 3 years ago

Hello, Thank you for the reply back. What if I put like a transparent say wall around the whole track. would that work?

joseph

kennardconsulting commented 3 years ago

Yes, sure - that would stop people leaving the raceway entirely. But it's not going to stop people coming off the track at individual corners (i.e. going 'on to the grass') and you wouldn't be able to use it for track barriers around certain corners (as they would need to be placed diagonally). But it would be fine for barriers along the straights and/or the pits/stands (as they can all be axis aligned, I imagine).

Therealjosephchrzempiec commented 3 years ago

I have walls that are the same as the whole track. I took them out because it looked funny to me. It covered the whole track. The track is in the sky track. I can put the walls back and make them transparent. So it will cover the whole track on both sides.

Joseph

Therealjosephchrzempiec commented 2 years ago

Hello. Do you have a example on how to not walk through walls. I' having a hard time setting up your code please?

Edit: This is what I have.

<a-curvedimage src="border.png" radius="500" position="300 20 0" theta-length="360" height="4" rotation="0 0 0" opacity="1" side="double" scale="1 1 10" reset-on-collision="with: .wall"></a-curvedimage>

Can you tell me what I'm doing wrong. I'm sorry I'm new to all this. I have a border around my whole scene.

Joseph

kennardconsulting commented 2 years ago

You're thinking about this wrong.

You must have an entity (the player) that has reset-on-collision="with: .wall"

Then you create walls that are aligned AABB (i.e. not diagonal) and give them a class="wall":

image

Therealjosephchrzempiec commented 2 years ago

Hello is this correct?

`a-curvedimage class="wall" src="border.png" radius="500" position="300 20 0" theta-length="360" height="4" rotation="0 0 0" opacity="1" side="double" scale="10 10 10">

a-entity camera reset-on-collision="with: .wall" look-controls wasd-controls="acceleration:200" position="160 20 -50"></a-entity`

kennardconsulting commented 2 years ago

You can't use 'curvedimage'. Use plane instead.

Therealjosephchrzempiec commented 2 years ago

Not sure how to make a Plane around the whole scene so no one can go off the edge? Sorry I'm not very good at coding. It is what I found online and modded to add to my own scene.

kennardconsulting commented 2 years ago

You'll need at least 4 planes. One for each edge. Look at my example of a 'back room' of a house

Therealjosephchrzempiec commented 2 years ago

Hello I'm just trying to upload a box for text to walk through and I got this. But when I try to refresh my scene webpage the scene won't load.

Untitled2

My coding is not so good But I'm trying.

kennardconsulting commented 2 years ago

The wall must be AABB. So rotation of 0 0 200 isn't good. Look at my example. Everything is 0 90 0 or 0 180 0 or similar.

Therealjosephchrzempiec commented 2 years ago

Hello I can not find a example But a art gallery one and That for some odd reason doesn't load. I change the rotation. However I can still not load the scene it comes up blank for some odd reason.

kennardconsulting commented 2 years ago

It's not a standalone example. It's a bit of code from an art gallery project I wrote.

But you can see it has planes for walls and a moving player. Just copy the planes for the walls and the player and put it in a project of your own. You should see the collision detection.

Therealjosephchrzempiec commented 2 years ago

Can you please give me a link? Because I can not find it or the example code?

kennardconsulting commented 2 years ago

image

Therealjosephchrzempiec commented 2 years ago

Hello, I did follow your wall. But the whole scene will not load now. If I take out the plane wall then The scene loads with no problem.

kennardconsulting commented 2 years ago

My code contains some things (like 'mixin') which you'll have to remove. Look up a tutorial on how to use a-plane.

Therealjosephchrzempiec commented 2 years ago

I don't have mixin in mine. That is the screenshot of mine currently as it is.

Untitled3

kennardconsulting commented 2 years ago
  1. I cannot see if you have closed your tags properly (they go off the screen).
  2. I would strongly recommend you indent your code properly.
  3. If adding some code breaks your page, look closely at that particular code
kennardconsulting commented 2 years ago
  1. You have spelt 'flase' wrong
kennardconsulting commented 2 years ago
  1. Single quotes 'red' are not valid HTML syntax. Must be double quotes.
kennardconsulting commented 2 years ago
  1. Check the JavaScript console. It will normally report errors
Therealjosephchrzempiec commented 2 years ago

I have clean things up a little and took out the building I have then change from a single qote to a double quote in the red. But the scene will not load. I also fixed the false from flase. Still again nothing loads.

Untitled5

kennardconsulting commented 2 years ago

Paste the code (not a screenshot) so I can copy/paste

Therealjosephchrzempiec commented 2 years ago

It will not let me paste whole thing. So i uploaded to pastebin. https://pastebin.com/aeKL92Zu

kennardconsulting commented 2 years ago

aframe.zip

Therealjosephchrzempiec commented 2 years ago

This is very strange. I laoded your code and It is a complete blank aframe. Here is a screen shot.

Untitled7

Therealjosephchrzempiec commented 2 years ago

I do not know why It is blank. If i take out the wall your plane for the collision part I can load the aframe with no problem.

Edit: I also put your reset-on-collision in the main area of the index.html page.

kennardconsulting commented 2 years ago

It works fine for me. I'm sorry I cannot help your further.

Therealjosephchrzempiec commented 2 years ago

Let me load this to my hosting and see if it works.

Therealjosephchrzempiec commented 2 years ago

OMG I can not believe it works in my godaddy hosting but bot in my localhosting. I wonder why is that?

Thank you so much for the help.

kennardconsulting commented 2 years ago

CORS, probably. Check your JavaScript console.

Therealjosephchrzempiec commented 2 years ago

Yup there is something there. I totally forgot to check that.

Uncaught TypeError: Cannot read properties of undefined (reading 'constructor') at extendProperties (component.js:736) at i.callUpdateHandler (component.js:416) at i.updateProperties (component.js:300) at HTMLElement.value (a-entity.js:490) at HTMLElement.<anonymous> (a-entity.js:727) at i.tick (reset-on-collision.js:41) at HTMLElement.value (a-scene.js:740) at HTMLElement.value (a-scene.js:790) at bind.js:12 at u (three.js:19157)

kennardconsulting commented 2 years ago

I just fixed that for you. Get a fresh copy of reset-on-collision.js

Therealjosephchrzempiec commented 2 years ago

Hello, I have one question. Would this work for a building to stop walking through the wallsbut Still can let the person walk through the door?

Joseph

kennardconsulting commented 2 years ago

Yes

Therealjosephchrzempiec commented 2 years ago

Do i apply it the same way? I have a OBJ building with MLT texture images.

Joseph

kennardconsulting commented 2 years ago

No that won't work. It would have to be a building constructed manually out of planes. Or you could probably use a OBJ and put invisible planes around it.

Therealjosephchrzempiec commented 2 years ago

The building i have and found is from here https://www.cgtrader.com/free-3d-models/exterior/industrial/modular-warehouse

Joseph

Therealjosephchrzempiec commented 2 years ago

Okay, I hope I can try tis. Thank you

Joseph

Therealjosephchrzempiec commented 2 years ago

Hello just a update. Everything is working great in local. however If i push my way through the red or blue wall I can get through If i keep pushing on the up arrow key. I just wanted to let you know.

Joseph

Therealjosephchrzempiec commented 1 year ago

Hello kennard, I'm sorry I have been away dealing with family and my depression. But I'm back at dealing with this whole walking through the wall problem.

I have tried your demo. If I keep trying to walk through the wall. It keeps pushing me back. However after I keep pushing through it I can get through the wall.

Is there a way to stop that?

Joseph