Share my AI design

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)----------]
:laughing: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.

You could use the A* algorithm for pathfinding.

To detect obstacles and cliffs you could check if the distance between the next position the bot will walk to ( P ) and the nearest walkable position( P ) is smaller than some small number. If the distance is bigger you know that P is not a walkable position.

“Throttle” is a vector right? As P you could use position of(event player) + throttle I think.

Depends on the throttle, sometimes it can be a direction or just “forward”, “backwards” and “sideways”, there is a third form of throttle but I forgot what it was

this might help

Thank you for your help, but this is not the answer I want.
I tried to make the problem clear.

Now I know how to get the character’s face to the rear, left, right, top and bottom, and create a sphere in front of the character and let it rotate in the direction of the face.

But there is a problem here. If I try to make the sphere create the left or right side of the facing direction, it will not remain on the left or right side of the character when the orientation changes.

I am here to put the demo code: CNP80

You can see that when you change the facing direction, the white ball is always on the front of the character, and the distance is the same. But the red ball is sometimes on the left and on the right, and the distance has been changing.

All I want is to have the sphere on the left or right side of the character have the same effect as the white ball when changing in the face.:disappointed_relieved:


i still think thats what u need
r u sure u didnt miss smth?
this is the code from the link: 6YMYC
take brig and use shield so u can see it in 3d person

*this code uses some variables but u can do it without variables too

Oh, damn, long hours of thinking have distracted me. You saved my life!
I have to go to sleep first to study how this works. When I finish my goal, I want to thank you in the post!:rofl:

thx but i didnt create it, someone sent it to me her when i asked a similar question

The solution nutellaman suggested you is a good one, but you can do this with a lot less code by doing this: world vector of(left, event player, rotation and translation), or world vector of(multiply(left, r), event player, rotation and translation) with r being a real number.