Jump to content

How to find out if a position is blocked by an object

Dimitri Stupakis

Recommended Posts


I created a garage with multiple parkout points and I want to check if a spawnpoint is blocked by something (car) or not before spawn it.

Does anyone knows how to find out whether a specific position is blocked by an object or not??
I tried it with raycasting which works but therefore a huge amount of positions needs to be set and sometimes based on the size of the vehicle it doesn't hit it...

I also tried to check it out by checking all owned vehicles but it always says "parking positions blocked"... :(

  bool freeSpawnAvailable = false;
            GarageSpawn freespawn = null;

            garage.Spawnpoints.ForEach(spawn =>
                if (!freeSpawnAvailable)

                    for (int i = 0; i < VehicleService.GarageService.OwnedVehiclesList.Count; i++)
                        OwnedVehicles blockingveh = VehicleService.GarageService.OwnedVehiclesList;

                        if (blockingveh.ActiveHandle != null)
                            if (blockingveh.ActiveHandle.Position.DistanceTo(spawn.Position) <= 4f)
                                freeSpawnAvailable = false;
                            freeSpawnAvailable = true;
                            freespawn = spawn;

            if (freespawn == null)
                c.SendNotification("~r~Kein freier Ausparkpunkt!");


Any ideas ??

Thanks a lot upfront for tipps, hints or example.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...