sorry if this is the wrong category, pls lmk and ill update it, thanks! ^^
so im in a bit of a tough spot rn. I am participating in a gamejam, and submissions close the 19th. I have a team of one other scripter, a builder, and an animator. Some of our progress below can be seen. (we’ve done more this is just some older stuff from a few days ago)
now, the game is inspired by AC (assasin’s creed) syndicate, and the idea is for players to run around and sneak into buildings and restricted areas, where guard npcs will patrol. the player’s goal is to attempt to steal valuables and sell them for upgrades on armor, weapons, and combat skills.
we’ve completed the basics, but we’re having trouble establishing the core gameplay loop. we have the objective established, its just creating the npc that’s the problem. i plan on using y3llow mustang’s soldier tutorial (https://www.youtube.com/watch?v=IWQnN7vPNZQ), but i want to make it so that there’s a specific boundary the npc walks in, and if they find a player inside that boundary, they warn them to exit, and if after 5 seconds they’re not out of the boundary, they become hostile (similar to how AC syndicate npcs are)
im wondering how i could do this? my teammate scripter attempted to make an npc and i tried to fix his errors, however i couldnt. how could i make s sytem like this?
you’d probably just make a region with something like Region3, a part, or with a module like Zone+ (or whatever you wanna use) and detect when they enter the zone.
you could have a variable or something to set to true in that detection code.
make sure to add something in there that’ll yield for 5 seconds and then check the value of the variable to see if they’re still in the region.
then you’d just have a listener for when they leave the zone, in there youd just set the variable or whatever to false.
or you could check the distance from the guard to the player every 5 seconds and yknow, check if the player is still close.
of course there’s multiple ways to do something with programming so these are only 2 approaches you can go with. good luck.
it does, the only shape it has to be is in the same as the layout of any building/area the section divides, so perhaps to keep it inside the boundary with multiple parts id just union it. i think if i did something like that then got the center of the union it would be the same as the circle and npc magnitude!
This kinda complicates things Im ngl because your building could have a weird shape. If you did simple boundary shapes like squares, rectangles, and circles, it would certainly be easier to set the bounds of the NPC. You could just create a part and set it where you think the center is, grab its position, and then delete it
alr, sounds good; i think ill add just a square covering the entire building, make it transprent non-col and no-query, then do that. maybe that could work better? (like if theres a church with a garden or a castle with multiple branches of building, ill just round all that up in a big square)
If you created a bunch of non-collision parts for the npc’s areas, and then create a table of cframe inverses and size/2. Then you can run each player’s position through each pair in the table.
Throw that code into an actor and run it in parallel (ConnectParallel usually) and there you go.
woah; brain failure right there LOL. ive heard of actors but never really used them, nor have i heard much on inverses in coding. thank you, ill look very deeply into this!!
I really like the WorldRoot options but I will note they are not the fastest as they tend to lack optimizations and are overkill in certain contexts.
You got GetPartBoundsInBox, GetPartBoundsInRadius, GetPartsInPart for overlap detection
And then you have Raycast, Blockcast, Spherecast for raycasting options
Parallel notes:
Most of the functions in WorldRoot are parallel safe. To use parallel your script needs to be inside of an Actor. Generally speaking you can call task.desyncronize() or you can do ConnectParallel.
local RS = game:GetService("RunService")
RS.PostSimulation:ConnectParallel(function(dt)
-- run calculation (reading cframes is okay in parallel as well)
-- generally use workspace as the WorldRoot
task.syncronize()
-- tell npc to move
end)