News › Forums › RAIN › General Discussion and Troubleshooting › Trouble detecting Players, Photon Networked
Tagged: detection, Photon, player object
This topic contains 6 replies, has 2 voices, and was last updated by JeffTech 3 months, 1 week ago.
November 12, 2022 at 11:55 am #34106
The player gameobjects are renamed to username of the player when they are instantiated in the scene, detecting is an issue I can’t seem to figure how this would be done. The Entity Form is requiring the gameobjects name, any ideas or tutorials on setting this up for photon?
Thanks RobertNovember 12, 2022 at 1:08 pm #34111
The Entity Form links to the object itself, not the name of the object. Changing the name of the game object at runtime should have no impact on sensors.November 12, 2022 at 1:11 pm #34112
I found the problem, thanks. Are there any good tutorials for scripting firing a projectile (attack) using Rain?November 12, 2022 at 1:39 pm #34113
Not really. Generally RAIN would be used to trigger the action (gun firing bullet) but wouldn’t be responsible for managing the actual projectile or any of the game-related logic. Usually a Gun Manager or similar would do that. The Bootcamp demo from Unity is a bit complicated, but does have a GunManager you can look at. Also the Tornado Twins have a package called FPS Control that is free on the asset store. It uses an older version of RAIN and simulates gun fire - may be worth looking at.
I’ll also put in a plug for our Squad Command: Advanced Warfighter AI package on the Asset Store. It is a working example of a battle scene that includes re-usable components for aiming, firing, health, and many other capabilities. The purpose of the package is to give developers a head start on rigging up shooter scenes with good AI, using RAIN.November 12, 2022 at 1:50 pm #34114
That’s cool, thanks! Is there a tutorial for the trigger action setup? One more question, I have the ai forever detecting in the first part and then splitting up between patrolling and moving toward the player… how do you get it to return to patrol if the player is no longer in range?November 12, 2022 at 5:09 pm #34117
We don’t have a specific tutorial for triggering an action. However, the general approach is to use a Custom Action whenever you need to interact with game logic/game code. Custom Actions let you define your own code, and can be used to define normal behaviors (like move and detect) that vary from the built-ins, special calculations (like calculating the distance between objects and setting the result in a memory variable), and making calls into non-RAIN code (like finding a component on the ai.Body using ai.Body.GetComponent<type>() and then calling a method on it.)
For your second question - there are different ways to do it based on how you want the logic to work. The simplest way would be to add a constraint node as a parent to your “moving toward the player” behavior. A constraint node checks a condition every frame and fails/exits whenever that condition becomes false. If your constraint condition is “player != null” then the move behavior will fail whenever the player is missing. You could do the same for patrol - with a condition of “player == null”. Then create a structure like:
— DETECT (REPEAT FOREVER)
— SELECTOR (REPEAT FOREVER)
— — CONSTRAINT (player == null)
— — — PATROL
— — CONSTRAINT (player != null)
— — — MOVE TO PLAYERNovember 12, 2022 at 8:35 pm #34125
That was a simple fix, thanks… AI is now returning to patrol. The custom actions part will have to wait for tomorrow, I understand what you mean I just need to see how it’s entered in Rain. I take a look at that project you mentioned.
You must be logged in to reply to this topic.