- Home /
Racast working when previewing the object but not when object is made
hey I'm making a building game and the way it works I need the walls to detect if there is anything close to it in order to prevent the player from making Rooms that can lead to dead turns.
code EX: Detection----------------------------------------------------------------------------------------------------------
public bool LeftsideFree()
{
return Physics.Raycast(wallCheck.transform.position, Vector3.left, 50);
}
public bool RightsideFree()
{
return Physics.Raycast(wallCheck.transform.position, Vector3.right, 50);
}
public bool FrontsideFree()
{
return Physics.Raycast(wallCheck.transform.position, Vector3.forward, 50);
}
Execution-----------------------------------------------------------------------------------------------------------------------
private void FixedUpdate()
{
Debug.Log(LeftsideFree());
Debug.Log(RightsideFree());
frontavalible = !FrontsideFree();
leftAvalible = !LeftsideFree();
rightAvalible = !RightsideFree();
}
When I have the room in preview mode so the player can see what the room will look like when its made the code works judging the distance of surrounding objects and tells me that it wont be able to make anything in that direction, But when I confirm the room creation the raycast then stops detecting anything and starts staying true to everything.
there's nothing in the creation void that tells it to do anything else and nothing on the detection code to change when Constructed it just Lies to me
Construct Code EX
public void ConstructRoom(RommSelectionInfoReader romm)
{
confimrTime = 0;
if (romm != null)
{
for (int i = 0; i < romm.roomInfo.MaterialsNeeded.Length; i++)
{
switch (romm.roomInfo.MaterialsNeeded[i])
{
case MATType.Steal:
GameManager.instance.StealResource -= rommSelection.roomInfo.Cost;
break;
case MATType.Brick:
GameManager.instance.BrickResource -= rommSelection.roomInfo.Cost;
break;
case MATType.Glass:
GameManager.instance.GlassRecource -= rommSelection.roomInfo.Cost;
break;
case MATType.Stone:
GameManager.instance.StoneResource -= rommSelection.roomInfo.Cost;
break;
case MATType.Wood:
GameManager.instance.WoodResource -= rommSelection.roomInfo.Cost;
break;
case MATType.Gold:
GameManager.instance.GoldResource -= rommSelection.roomInfo.Cost;
break;
}
}
Destroy(GameManager.instance.dungeonMaker.WalltoDevelop.GetComponent<DungeonWallInteract>().parentObj);
GameManager.instance.dungeonMaker.TotalRooms.Add(previewObj);
previewObj = null;
GameManager.instance.dungeonMaker.DungeonMenuClose();
SetListedValues(rommSelection);
}
}
Anyone have any Ideas as to what is happening, there is no real difference for the object when its considered a preview object but it changes when it stops being classified as one
Your answer
Follow this Question
Related Questions
Ray is not being detected 0 Answers
Is this way of making a raycast correct 2 Answers
how to setup raycast firing system in this situation 1 Answer
Door script using Raycast 1 Answer
Raycast is not setting false, however is able to be set to true. 3 Answers