0
Answered

Physics2D can't connect to Branch

George Robson 6 months ago updated by Lazlo Bonin (Lead Developer) 5 months ago 2

I'm having an issue with this script. The intention is to check the next tile in the game for an object with collisions and then proceeding to move to that tile if there isn't an object blocking the way. 

In C# it would be:

if (!Physics2D.OverlapCircle(movePoint.position + new Vector3(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"), 0), 0.2f, collision)

But as you can see below, I'm having trouble replicating that within Bolt as I can't connect the overlap circle to the branch. Would anyone be able to point me in the right direction so that I can solve this? 

I'm very new to Bolt so it may be that my script is set up wrong but based on the line of code it looks like it should be correct.

Bolt Version:
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):
Answered

Hi George!

You'll want to compare the output of OverlapCircle (white page) with an Equal unit, and check that it is not Null. Unity does this for you behind the scenes in C# (if you convert a component or game object to a boolean, it actually returns the result of a null check), but it's generally compared bad practice, so Bolt does not replicate this quirk.

Or, more simply, you could use the Null Check unit which does this branching for you! In that one, you can pass the output of OverlapCircle directly as the input.