Discussion - Tycoon Spawning

I’m trying to work out what to do when a character is in the way of a newly spawning tycoon model. Should I worry at all? Do characters get stuck? How do other developers handle this mechanic?

2 Likes

just teleport them to the front of the door when they spawn in a tycoon, that should work

no I mean if another player is standing on the spawn location when player A is choosing the tycoon.

If you’re worried about the player being stuck inside of a tycoon, you would want to teleport them out of the area when the tycoon is being created. There’s all sorts of different ways you can go about this, the methods that I could think of are as follows…

  • Calculating the magnitude of players from the centre point of the tycoon, and using that magnitude to determine whether the player has to be teleported away
  • Temporarily instancing a part with the size of the tycoon on the designated plot, and checking to see whether any players are inside of it, if so, teleport them away
  • Most tycoons have a base for each plot, the same mechanic can be applied with the above method where the base is used instead of instancing a large part

Calculating the magnitude of each player is the method I would recommend as it’s the most reliable due to not using the physics engine compared to the two other methods, but it would depend on your circumstances and how your game is laid out.

Ok that’s a new one I hadn’t considered. I didn’t want to run a temporary part with a spacial query to make sure the area was free. Since I already have the location for the tycoons cframe and position of the area, would you suggest I loop through all players in the game and get the character positions. I’ve never use magnitude before so I’ll have to read up on that…then umm, what is this a correct method?

Yes, that would be correct. You would want to iterate through each player and their character and find the magnitude (the distance between one position to another, measured in studs) using the player’s HumanoidRootPart and the centre point of the tycoon. If the magnitude is of a certain value (the lower the value, the closer the player is), position them away.

You can find the magnitude using .Magnitude in conjunction with the difference between the tycoon’s centre point position and the player’s HumanoidRootPart position.
For example…

local distance = (centrePoint.Position - humRoot.Position).Magnitude

if distance <= 20 and spawningTycoon == true then -- Player is within 20 studs (or less) of the tycoon plot
    -- Do stuff
end
1 Like

And I’m assuming I would check both X and Z coords as the tycoon isn’t a perfect square? This is very helpful, tyvm. Was going out of my mind with overly complex solutions.

1 Like

Yes, you may need to check coordinates if necessary. Additionally, I would recommend having the centre point near or in the ground, as having the centre point high up would make the magnitude larger than expected if the player is only expected to roam on the baseplate/ground.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.