Let me share my design.
Code:
8KAFN new~
95VZ8
Make sure you stay in Team 1, enter the game and press the “Interact” button to create a bot at the aiming position.
In my design, the script first checks if the player is in the bot’s line of sight and marks it as “true” or “false” in the bot’s player variable A(0).
If A(0) is “true”, the bot will face the nearest player and move to the player. The closest player is “A(1)”, the face is “A(2)”, and the move is “A(3)”. When A(0) is “true”, A(2) and A(3) will be given the position of A(1) to achieve this.
If the player is beyond the bot’s line of sight, the script will record the player’s final position, allowing the bot to go there, as if the real human player would do it, to search (probably) where the target disappeared.
When the bot reaches the player’s final position and the player is not visible, the script will cause the bot to go to a random location on the map while facing a random direction, which will increase the probability of finding the player and more like a human player.
The above content can only be valid at a height close to both sides.
Problems being improved:
1. Try to get the bot around the obstacle. (√)
2. Try to stop the bot in front of the cliff. (√)
3. Try to get the bot to navigate.
My thoughts:
This is a bit complicated. I use “RAY CAST HIT POSITION” to mark a coordinate (player variable B(0)) 2 meters in front of the character’s eye position, which will be less than 2 meters from the eye position when the character touches the obstacle. (B(1)).
This way I can make the character move left or right when B(1) is less than 2 meters until there are no more obstacles in front.
Based on this, I use “RAY CAST HIT POSITION” again to mark a new coordinate B(2) directly below the coordinate B(0). Measure the distance from the player position coordinates to B(2) (B(3) ).
As long as B(3) is greater than 5 meters, it will cause the character to stop moving in this direction.
Repeat this process to the rear of the character, left and right. Now I have eight distance parameters in four directions. The horizontal direction measures the wall and the vertical direction measures the cliff.
But as you can imagine, this means that I have used at least 16 variables for this purpose, and I have been looping through it, with a server load of about 30 to 40. Coupled with complex move systems, it puts a lot of pressure on the server load. I will think about how to optimize this program.
Probably like this:
player
[---------B(1)----------]
o-------------------→
||///////////////////|
||///////////////////|
||///////////////////o ^
____________////////|
ground /////////////|B(3)
///////////////////////|
///////////////////////↓ v
Resolved issue
Let me ask a question now.
I can create a sphere 1 meter in front of the character, let the sphere rotate with the character’s perspective and always stay in front of the character. (only consider X, Z)
ttps://flic.kr/p/2h7mhdb
Now I want to keep this sphere 1 meter to the left of the character, and also to rotate with the character’s perspective and maintain the relative position of the character.
ttps://flic.kr/p/2h7oPUN
Can anyone help me with this problem?(The picture clearly expresses my meaning but I can’t use the link.)
This is how I create a sphere on the front of the character:
ttps://flic.kr/p/2h6WJaC
Thanks to nutellaman for the reply, the code 6YMYC shared with the Twitter user nakamoooooo.