playMaker

Author Topic: [SOLVED]Another ingame building issue  (Read 2282 times)

eirsik

  • Playmaker Newbie
  • *
  • Posts: 22
[SOLVED]Another ingame building issue
« on: July 12, 2014, 10:33:44 PM »
Hi all!

Yeah I know, another ingame build thread...

I've searched and read a lot but I really can't seem to get the collision test to work.
What I want to accomplish is that when the player select an object to build from the menu is spawns and follows the mouse until clicked to be placed.

So far everything is working! :)

The issue I have is to check if the object being places is collision with anoter object, like a tree or a rock.

I've tried RayCasting but I can't get it to work properly, what I really wanted was to have a 360 raycasting around the object to see if anything is in conflict with the object, but that may be hard to do.

The issue with Raycasting is that it draws a small line from the object out into the world, but my object is sometimes big and a small line from the middle wont help if the object is colliding with its corner etc.

Anyway to solve this issue?

Have read about having box colliders at trigger zones where it is ok to build but it would be pain in the ass to setup those boxes in a forest with hundreds of trees and stones!

Thanks in advance :)!
« Last Edit: July 13, 2014, 03:27:24 PM by eirsik »

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: Another ingame building issue
« Reply #1 on: July 12, 2014, 10:36:52 PM »
There's a custom action on here somewhere called SphereCast. That might be helpful to you.

redikann

  • Full Member
  • ***
  • Posts: 174
Re: Another ingame building issue
« Reply #2 on: July 13, 2014, 02:33:30 AM »
Remember that rigid bodies and character controllers are the only things that register a collision. So if the object in question has a collider but no rigid body how would Unity know when a collision occurred.

eirsik

  • Playmaker Newbie
  • *
  • Posts: 22
Re: Another ingame building issue
« Reply #3 on: July 13, 2014, 06:18:50 AM »
Remember that rigid bodies and character controllers are the only things that register a collision. So if the object in question has a collider but no rigid body how would Unity know when a collision occurred.

Exactly, I know! But the SphereCast worked like a charm!

There's a custom action on here somewhere called SphereCast. That might be helpful to you.

Thanks you so much! Worked just perfectly!


A quick question: Is there a way to check if the terrain slope is less than X before placing the object, and if its greater then X then do not allow building?