How to spam different bot models ?

General support.
User avatar
MAC
Contributor
Contributor
Posts: 77
Joined: Sun May 27, 2018 7:59 am

Fri Jan 17, 2020 2:16 am

Hello,

How can we spawn bots, with different models for each map and for each team?

Will be very helpfull .

thank you
User avatar
Fata1Err0r
New Member
New Member
Posts: 6
Joined: Wed Jan 15, 2020 10:13 am

Fri Jan 17, 2020 6:41 am

MAC wrote:
Fri Jan 17, 2020 2:16 am
Hello,

How can we spawn bots, with different models for each map and for each team?

Will be very helpfull .

thank you
I can't see your code to tell you exactly, but I imagine there is a script that's setting your model based upon whatever team you've selected. You could potentially utilize that script and simply add in some additional checks to check the map / team before setting the appropriate model to the "player." If that type of script doesn't exist, then you could create it and have it perform the checks/set the model before the map launches. This would make it possible for you to have a diff model for each map, such as a winter soldier on the snow maps and a jungle soldier in the bush type maps.

Again, it's hard for me to solve your problem with specifics since I'm unable to see your code or setup, but that's a general means of going about your task. I hope that helps you out a little bit.
User avatar
Lovatto
Admin
Admin
Posts: 1511
Joined: Sun Dec 07, 2014 3:18 pm
Contact:

Sat Jan 18, 2020 7:08 am

MAC wrote:
Fri Jan 17, 2020 2:16 am
Hello,

How can we spawn bots, with different models for each map and for each team?

Will be very helpfull .

thank you
For each team, you simply need to set the prefab in GameData -> BotTeam1 or BotTeam2,
now for each map, you will need to modify the code, in short, simply transfer the BotTeam1 and BotTeam2 variables from bl_GameData.cs to bl_AIManager.cs,
then in each scene set the bots prefabs that you want for that map in AIManager -> bl_AIManager -> BotTeam1 or BotTeam2.
User avatar
MAC
Contributor
Contributor
Posts: 77
Joined: Sun May 27, 2018 7:59 am

Thu Jan 23, 2020 4:27 pm

Hello,

Thank you for your respond, but its not realy what i wanted to do and idk how to transfer these variable : )

What i trying to do its more like a random models spawn bot

Because your are slot limited by 1 models bot by team, bot team1 and 1 team2
I need like 5 bot in each team, so i need having 5 slot and its not working because the limiting at 2 team.

Thanks

Cheer
User avatar
MAC
Contributor
Contributor
Posts: 77
Joined: Sun May 27, 2018 7:59 am

Tue Jun 23, 2020 10:48 am

Lovatto wrote:
Sat Jan 18, 2020 7:08 am

For each team, you simply need to set the prefab in GameData -> BotTeam1 or BotTeam2,
now for each map, you will need to modify the code, in short, simply transfer the BotTeam1 and BotTeam2 variables from bl_GameData.cs to bl_AIManager.cs,
then in each scene set the bots prefabs that you want for that map in AIManager -> bl_AIManager -> BotTeam1 or BotTeam2.
Hello M. lovatto,
Well i'm up whit this problem again..
I try to create a random spawn bot .. again..
Like i have 5 models of differents bots , and i want to spawn them like :
- bot 1 spawn ,is dead, so spawn the bot 2 ,
- bot 2 spawn, is dead, so spawn the bot 3 and etc
the problem that i doesnt undesrstand how to do that.. i'm not coder..
So i know the logic but idk how to make it in code ..

Or maybe something like this idk :

Code: Select all

 [Header("Bots")]
    public bl_AIShooterAgent BotTeam1; 
   Model 1
   Model 2
   Model 3
    public bl_AIShooterAgent BotTeam2;
    Model 1
    Model 2
    Model 3
I think it's look easy for you ..adding a little 2 line code for do it and voila..but not for me x )
Because a team where you alway spawn 1 model bot is a clone team i can't do it like this : )
Hope you have 5 min tomake a look at this system .
Have a good day!
User avatar
killa187
Contributor
Contributor
Posts: 54
Joined: Thu Apr 23, 2020 7:46 pm

Thu Jun 25, 2020 5:25 pm

MAC wrote:
Fri Jan 17, 2020 2:16 am
Hello,

How can we spawn bots, with different models for each map and for each team?

Will be very helpfull .

thank you
this script you can use on any game object in main menu or empty one.populate bots var array with your bots and will spawn random each new match use the other script i sent i made mistake on this one sorry
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System;
public class AddBotsRandom : MonoBehaviour
{

public GameObject[] bots;
public bool h = false;
public int b1 =0;
public int b2;
public float switchTime = 10f;
public GameObject preChar;
// Start is called before the first frame update
void Start()
{
b1 = PlayerPrefs.GetInt("peviousnum", b1);

bots[b1].SetActive(true);
preChar = bots[b1].gameObject;

}

// Update is called once per frame
void Update()
{
switchTime -= Time.deltaTime;
if(switchTime < 0f)
{
switchTime = 10f;
b2 = (int)UnityEngine.Random.Range(0f, bots.Length);
preChar.SetActive(false);
PlayerPrefs.SetInt("peviousnum", b2);
bots[b2].SetActive(true);
preChar = bots[b2].gameObject;
}





}
}
User avatar
killa187
Contributor
Contributor
Posts: 54
Joined: Thu Apr 23, 2020 7:46 pm

Thu Jun 25, 2020 5:30 pm

MAC wrote:
Fri Jan 17, 2020 2:16 am
Hello,

How can we spawn bots, with different models for each map and for each team?

Will be very helpfull .

thank you
sorry last one was for another thing but never finished this is one you want to use on any object in menu

using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System;
public class LoadOutSwitch : MonoBehaviour
{
// Start is called before the first frame update
public bl_AIShooterAgent[] bots;
public bool h = false;
// Start is called before the first frame update
void Start()
{
int b1 = (int)UnityEngine.Random.Range(0f, bots.Length);
int b2 = (int)UnityEngine.Random.Range(0f, bots.Length);

bl_AIShooterAgent oldBot = bl_GameData.Instance.BotTeam1;
bl_AIShooterAgent oldBot2 = bl_GameData.Instance.BotTeam2;
bl_GameData.Instance.BotTeam1 = bots[b1];
bl_GameData.Instance.BotTeam2 = bots[b2];
}
// Update is called once per frame
void Update()
{

}
}
User avatar
MAC
Contributor
Contributor
Posts: 77
Joined: Sun May 27, 2018 7:59 am

Fri Jun 26, 2020 8:34 am

Hello Killa,

Well thank you for your help !
It is whats i want to do, but for now it's not fonctionning ..
Ill try to working on it in bit and i back for some news : )
User avatar
killa187
Contributor
Contributor
Posts: 54
Joined: Thu Apr 23, 2020 7:46 pm

Sun Jun 28, 2020 8:18 am

MAC wrote:
Fri Jun 26, 2020 8:34 am
Hello Killa,

Well thank you for your help !
It is whats i want to do, but for now it's not fonctionning ..
Ill try to working on it in bit and i back for some news : )
Did you get it going
User avatar
killa187
Contributor
Contributor
Posts: 54
Joined: Thu Apr 23, 2020 7:46 pm

Sun Jun 28, 2020 8:19 am

MAC wrote:
Fri Jun 26, 2020 8:34 am
Hello Killa,

Well thank you for your help !
It is whats i want to do, but for now it's not fonctionning ..
Ill try to working on it in bit and i back for some news : )
Oh and your very welcome lol
Post Reply