Physics not registering..

I’m going to keep doing my research but just figured I would post this in case I got a answer faster here.

My Code

function OnTriggerExit(other : Collider){
	if(other.tag != "Ground"){
		isColliding = false;
	}	
}

function OnTriggerEnter(other : Collider){
	if(other.tag != "Ground"){
		isColliding = true;
	}
}

function OnTriggerStay(other : Collider){
	if(other.tag != "Ground"){
		isColliding = true;
	}
}

function getIsColliding(){
	return isColliding;
}

Basically what I am trying to do here is. I have a object I drag around once its not colliding I can place it on the map.

Lets say I setup 5 objects right in a row. Then I have one I am dragging around. If I click on the place object button a bunch of times(which calls the getIsColliding function) sometimes its like it glitches and lets the object get placed on top of another. 95% of the time it registers as its colliding the other 5% it don’t. I understand that I probably don’t need onTriggerEnter and onTriggerStay but just have it in there to show what im trying and whats not working.

Any ideas would be helpful. I have it ignoring the ground collision as I don’t need to worry about that right now. I need to know if it collides with any of my other objects placed on the ground.

Also would like to add it seems to only happen when I am moving the camera. It doesn’t every do it when I am standing still.

No ideas?

I don’t know why but even after reading your topic three times, I don’t understand :sweat_smile: can you ask a simpler question, please ? In my current state (lol), I don’t have any clue ^^’

Well I guess its a normal problem with objects moving “to quick” and its not registering the collision fast enough.

What I have is 5 buildings in a straight line. Then if I have a 6th building attached to the center of the screen which lets me drag the building around until I figure out where I want to place it. When I have a location to place it I click one of the UI buttons that locks the building into that slot.

What its not suppose to do is place a building when collision is detected. Whats happening is just at normal speed of the fpscamera script I click the lock object button really fast and it will glitch and let it be placed on top of another object.

– Potential Fixes I have found –
1)I will probably get rid of the rigidbody. On a fixed update I probably will sent out a few short raycast to see if they collide with anything. If so it wont let the object be placed.

Then when they click the lock button also send out a few short raycast just to be safe.

2)I read somewhere to try -
Edit → Project Settings → Physics → “Min Penetration For Penalty” Setting. Guess we can change this from .1 to 1 and see if it helps.

More than likely though I will just go with the raycast solution.

there’s a “dontgothroughthings” script on the unity wiki. You should try it out.