playMaker

Author Topic: Raycasting problem in tetris 3d like game  (Read 2450 times)

neutral

  • Playmaker Newbie
  • *
  • Posts: 5
Raycasting problem in tetris 3d like game
« on: February 06, 2014, 07:17:39 AM »
Hi,

I'm trying to make a Tetris 3d like game and I'm having some problems with raycasting.
I'm using raycasting to check whether I can  move on certain direction or not.
Basically I hit a button and I send a ray in that direction , if that hits something I don't allow movement in that direction.
In general it works, but it doesn't work when I'm for example on a corner, so it needs to hit in 2 directions or when I'm already touching a piece or a wall.
Any idea how to solve this problem, or any other way of handling this?
I've tried collisions but it didn't work because I need this to be directional.
Thanks.

Groo Gadgets

  • Beta Group
  • Full Member
  • *
  • Posts: 175
Re: Raycasting problem in tetris 3d like game
« Reply #1 on: February 18, 2014, 02:14:33 PM »
Heya,

It's hard to say without seeing your game in action but I have been making a similar block game and I had nothing but trouble with Ray casting and collisions.

I found the best way to handle block drops similar to Tetris was to create an array that stored the height of each column as an integer. This was simple since my blocks are 1x1. So when a new block is about to drop I check the array and drop it to a height determined by the column index.

I hope that helps.

Cheers,

Simon