Laurent PIERRON (Laurent.Pierron@inria.fr)
April 05, 2023
https://tutos-technos.gitlabpages.inria.fr/nsi-unity
Représenter les données d’analyse d’intrusion du Laboratoire de Haute Sécurité (LHS) sous la forme de sphères rebondissantes.
Unity gère le rendu 2D et 3D à travers plusieurs moteurs (URP, HDRP, Build-in)
caméras
éclairage : lumière, ombre
maillages, textures, matières, ombrages
effets visuels ( brillance, brouillard, flou, particules, etc.)
ciel, etc.
Unity gère les lois de la mécanique (physics en anglais) en 2D et 3D :
Prérequis :
Edit -> Preference -> External tools -> External Studio Code
ou une release : https://gitlab.inria.fr/tutos-technos/nsi-unity/-/releases
Should looks like
Nombreuses vues :
Scene | the current scene in 3D |
Hierachy | The list of GameObject |
Project | File manager in the project |
Inspector | Detail of the current selected GameObject |
… | Console, Game, Animations, Animator controler… |
Un tas de façon pour déplacer, ajouter, supprimer, détacher des vues.
Regarder la vue Hierarchy
3D Object | A list of cubes, spheres, plane, text… |
Effects | particles |
Lights | Different kind of lights |
Audio | Audio Sources |
Video | Video Sources |
UI | 2D buttons, text, checkboxes, … |
Camera | A camera ! |
Exercice: Ajouter un nouveau GameObject capsule, changer taille et position…exécuter
Tout est dans la vue Inspector d’un GameObject
Vous pouvez ajouter et supprimer des composants, changer l’ordre
Transform contient la position, taille et rotation
Mesh est la définition du maillage (sommets, arêtes et faces) de l’objet
Box collider décrit la collison entre les objets
Un RigidBody donne de la masse et de l’attarction à un objet
Exercice: Ajouter un RigidBody à la capsule…et zou!
…Object oriented, strongly typed…
A script is a Component attached to a GameObject
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[AddComponentMenu("HelloWord")]
public class HelloWord : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
Debug.Log("yeah !!!");
}
// Update is called once per frame
void Update()
{
}
}
Exercice: Add this script to the capsule…then run
Beaucoup de propriétés et de déclencheurs
Modifier le script pour avoir une message lors d’une collision
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[AddComponentMenu("Attraction")]
[RequireComponent(typeof(Rigidbody))]
public class Attraction : MonoBehaviour
{
[SerializeField, Tooltip("Attraction factor")]
public float AttractionFactor = 1;
[SerializeField, Tooltip("Minimum distance")]
public float MinDistance = 1;
[SerializeField, Tooltip("Maximum Force")]
public float MaxForce = 1;
public int port = 0;
// Start is called before the first frame update
public int count = 0;
Master | Get infos from HSL, and lauch Spawn |
Spawn | Create and throw a Sphere, change its CountryName and PortName |
Attraction | Compute attractions between spheres and add a force to the sphere |
Expire | Destroy the sphere after a while |
Bounce | Compute the Bounce and add a force to the sphere |
FlagMaterial | Download the png flag from internet and apply to the
sphere’s material. |
Fixed Text | Set the text right to the camera |
Une bonne application pour faire d’incroyable simulation !