A-Frame Camera Collision (please help me)

Repl link:
https://talk-to-bobby.daxcodes.repl.co/

I don’t know if anybody has the answer, because StackOverflow wasn’t very helpful, but here’s my problem.

So, I have been working on a non-VR desktop game with A-Frame called “Talk To Bobby”, a mini-horror game. One issue I have been having, though is figuring out how I could make it so the camera cannot go through objects (such as planes, boxes, etc.)

I have tried seeing anything I can find on the internet about an updated version of what I am describing, but no luck. If anybody can help, please.

Thanks,
DaxCodes1 (DaxCodes on replit)

maybe treat the camera as another collider?

1 Like

Sorry, i meant to have another entity at the same place as the camera and use that with collision.

1 Like

@python660 I have been trying to find out HOW to make it happen, because I don’t know anything about A-Frame collisions. I was originally trying to find something like a component that is included in A-Frame or A-Frame extras, etc., and I don’t want to recreate an entire collision system that much (like using another camera or coding a 150-line thing that adds a component unless it’s easy to implement)

I think it’s dumb that they removed one thing that would make it so easy to make this happen: kinematic-body in A-Frame Extras. If the only way to make collision right now is recreating it, I might scrap the idea in general.

Sorry if nothing makes much sense, because I don’t know how to word very well what I want to accomplish.

1 Like

me neither :cry:

I’m just being theoretical rn, but you know how you have a player, and how that player has collision? Add a variant of the player which has the same physics as the camera (NOTE: related to the player, not the camera!), then tie the camera to the entity floating around you.

To do collision, you need to have a collision system. Otherwise, have fun doing the math.


What game engine are you using?

1 Like

@python660 To the first question, there isn’t any physics to the camera. When a Y value is set, it just stays at that point (basically, there isn’t any gravity or jumping)

Secondly, it’s not a game engine, it’s a library called A-Frame. A-Frame makes it very easy to make VR experiences for the browser, where you can make objects within the experience with ease, but you can also make it so you can use it to make a non-VR desktop game (with WASD controls). I can see why they don’t have a built-in collision system because it isn’t very necessary from a VR point of view, where the main only transportation is teleporting.

I also don’t really think A-Frame was intended to make games on it either LOL.

1 Like

@python660 Thanks for trying to help me though, even if you don’t know anything about A-Frame!

I glanced at the docs.
The camera is a component attached to an arbitrary entity.
There is a collider system and component that allows you to detect collisions. Since the library uses ECS architecture (Entity Component System architecture), you can attach a collider to your camera entity.
Now that you can detect collisions on your camera’s entity, you probably just have to revert position when a collision happens if there is no builtin way of doing this.

1 Like

@NuclearPasta0 Thanks! I will try that!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.