Change Focus

Posts: 46
Hello,

I just got a question

How to switch the camera focus to a specific team?
Switching to a specific driver is no problem (ChangeCamera->Change Focus ->Value: Driver ID)

It looks like this is not working with Team ID's?

MfG

Christian
Posts: 785
I guess there is no way to directly address a team id right now. I could add it but I have to find a way for you to specify if you meant a team id or a driver id.

For now, you can also use the car number, is that a working solution?
Posts: 46
Yep the carnumber would make it too.
Could have tried that yesterday evening, completely forgot about it....

Btw, storyboards work fine now
Edited (1 time)
Posts: 11
Is there a way to switch camera focus onto a driver selected from a Driver Picker dropdown?
Posts: 785
You can already do that via the regular Camera Controls of course.

If you still want to do it in your theme controls, with a script you can do it. Unfortunately it looks like I never added actions to execute when the selected driver changes. I'll see if I can add that in the near future.

Meanwhile you can let your script run continuously (enable Auto-execute), and simply remember the selected entity and react when it has changed. Something like this should work. If you notice an impact on performance from the script running every update, you can always add a 'elapsed time' check to only execute if some time has passed.

using System;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
using ATVO.ThemesSDK.Data.Entity;

namespace Scripts
{
public class ChangeFocus : IScript
{
private IEntity _selectedEntity;

public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
var picker = item.Theme.DriverPickers.Find("DriverPicker1");
var entity = picker.SelectedEntity;

// Is anyone selected, and did the selection change?
if (entity != null && entity != _selectedEntity)
{
// Change camera focus
sim.CameraManager.Show(entity);

// Remember this is the newly selected entity
_selectedEntity = entity;
}

return null;
}
}
}

Edited (1 time)
Posts: 46
Have scripts access to the Textboxes?

In my case I could maybe create two textboxes where I'll enter the car numbers of the teams i want to change focus to.
For each Textbox there would be a script, that reads the value (carnumber), and switches the focus to that car.

To avoid making those scripts run the whole time, a storyboard could be used to call the scripts only once?

Sth. like this

Storyboard start
Wait 5 min
Execute script 1 (carnumber textbox1)
Wait 5 min
Execute script 2 (carnumber textbox2)
Restart Storyboard

Could that work?
Posts: 785
Sure, that works. I don't see the reason for a textbox in this case, two driver pickers would also work fine and make it easier to switch the camera. If you only have the car number I think you probably need to find the corresponding driver yourself, as I don't think our CameraManager allows switching focus to a carnumber directly.
Posts: 46
The CarNumber is interesting for endurance events.
Our Teams are always trying to make it i in one split together, by registering in a manner that their iRating is very close.

When you're in the session you only have to enter the carnumbers in the textboxes, an the script can focus the car even if the driver has changed.

ChangeCamera -> ChangeFocus -> Value #carnumber

This works.

For the 24h Nürburgring we had two cars in one Split and i made a storyboard to switch the car focus every 10 minutes.

The only thing i had to do was to enter the values in theme editor when the session started, an export the theme then.
The Textboxes would make it possible to enter the desirerd car number within atvo.

We had carnumber 5 and 15

It was like that

Storyboard start
Wait 10 min
ChangeCamera -> ChangeFocus -> Value #5
Wait 10 min
ChangeCamera -> ChangeFocus -> Value #15
Restart Storyboard
Edited (3 times)
Posts: 785
You can achieve this with a similar script:

using System;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
using ATVO.ThemesSDK.Data.Entity;
using System.Linq;

namespace Scripts
{
public class ChangeFocus : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
ControlInput input = null;

// Check if you want input 1 or 2
if (value?.ToString() == "1")
input = item.Theme.ControlInputs.Find("Input_CarNumber1");
else if (value?.ToString() == "2")
input = item.Theme.ControlInputs.Find("Input_CarNumber2");

if (input != null)
{
var carNumber = input.Text;
if (!string.IsNullOrWhiteSpace(carNumber))
{
// Find the corresponding entity (team entry)
var entity = sim.Session?.Entities?.SingleOrDefault(e => e.Car.Number == carNumber);
if (entity != null)
{
sim.CameraManager.Show(entity);
}
}
}
return null;
}
}
}


You can execute this script via the storyboard and also give it an input in the Value. This input is used in the script to check which input you want to use to get the carnumber. For example you can use "1" and "2" inputs, but you can easily extend this for more.

Once the input is found, you grab the Text to get the carnumber, and then find the corresponding entity. Then you can finally call the CameraManager again to show that entity.

The rest is a bunch of sanity checks to make sure the script does not throw errors (when you input an invalid carnumber or something or the carnumber is not in the session).