Jump to content

Interfacing with the World


Oafkad

Recommended Posts

  Vector math can be a bit of a pain in the ass sometimes. You do some logic that is probably higher than you ever actually finished in school and the damn raycast is going off in god only knows what direction. So naturally you throw in a gizmo to draw a line to where it is going. You adjust the logic in the gizmo until it is precisely what you want.

  Ok, fair enough, then you copy and paste that logic into your actual non debug code and...ok...why is it not working? I'm looking at this object and my debug log isn't printing? Then you turn and once you are at an angle that can only be described as "totally wrong" suddenly you see your debugs. Sweet, ok. Well, at this point there are two choices.

  Choice number 1 is to keep working at it, waste hours of your night, and honestly be unhappy even once it is working. Or you can work a little bit smarter and come back to it later only if you need to.

 

  Alright, well, as you can see. I went with Choice number 2. What we are doing here is quite simple. I've got an invisible collision object that is in front of the player at a specified distance. In this way I can check if that object intersects with any collision objects. If it does, I check if that object is implementing the IInteractable interface. If this is also true then we interact with it.

  Doing so in the case of this cube will increment your "Debug" item by 1 and pool the cube. But we'll talk about pooling more specifically in a future post since I've been having busier days than I expected. Ultimately though progress continues. With each passing day we have another feature ready.

  The next thing I would like to tackle is actually how you look around. Currently with a KBM setup the camera is always locked to your mouse cursor. I would like to adjust this, per suggestion from my wife, so that it only looks around when you press down a mouse button. That way you can adjust your looking angle and then keep that locked. I don't know why I didn't think about this sooner but that's why it is always good to get a second opinion.

Link to comment
Share on other sites

×
×
  • Create New...