Unity 3D. Utilisation des objets physique. Tutoriel 17

Dans ce tutoriel, le 17ème, le temps passe vite, je vous explique l’utilisation des rigidbody dans Unity ainsi que la manière de faire des appels clavier.

Le script du tuto est le suivant :

?Download download.txt
1
2
3
4
5
6
7
8
9
10
    function FixedUpdate () {
    transform.position.z=0;
 
    if (Input.GetKey("space")){
    if (transform.rigidbody.velocity.x>=30){
    transform.rigidbody.velocity.x=30;
    }
    transform.rigidbody.AddForce(Vector3.right*20);
    }
    }

WIP : un éditeur de splines

Unity tout comme Flash est un éditeur dans lequel vous pouvez ajouter des fonctions. En effet, si vous êtes assez doué en dèv, vous pouvez accroite les capacités de Unity dans divers domaines. FoxUmkov, un membre du forum officiel développe en ce moment un plug permettant d’intégrer des Splines dans l’éditeur afin de faire suivre à des objets un chemin définit.

Vous pouvez voir une ébauche dans cette vidéo.

Unity, les txt et les xml

Voici un article en anglais dans lequel vous serons expliqué les différentes méthodes pour lire un fichier txt externe ainsi qu’un xml. Vous trouverez des informations pour éviter les pièges liés aux différents types de plateforme (PC,Mac, Iphone).

Dans Unity Pro, il existe déjà une méthode pour charger des objets externes en streaming mais c’est plus cher 🙂

Sortie du A* Pathfinding 2.2

Je signale la sortie de la dernière version de A* Pathfinding. Il s’agit d’un projet complet permettant de créer un pathfinding dans votre jeu, en clair un système de reconnaissance de chemin.

Ce système développé par Aron Granberg marche même avec des chemins à étage et est assez idéal pour un RTS ou jeu en point and click. Je vous copie colle les features ci-dessous et vous pouvez télécharger le pack ici.

Features

Easy to set up
Requires no external data or code libraries
Very fast (see performance)
Can use multiple grids
3D pathfinding is supported
Runtime changing of the grid, for example placing a building on the ground
Node linking
Free for non-commercial projects
Can execute over several frames
Path caching
Path simplification
Options

Max slope
Formula options, H, G or H+G
Angle cost
Ability to choose between Four or Eight neighbours for each node.
Node size
Max frame time
And a lot more, see interface page
Performance

For example: A path resulting in a path with 83 nodes, searched about 660 nodes took 5 frames or 0.00603 seconds with 0.0015 seconds/frame
Another shorter path resulting in 45 nodes and searched 345 nodes took 1 frame or 4.196167E-05 seconds, i.e so short time I couldn’t measure it.
A quite complicated path, 152 nodes long, searched 20 268 nodes, took 0.28 seconds split over 15 frames.
Results can very very much so it is hard to give a good example.

Sortie de Unity 2.6.1

Mise à jour pour Unity qui passe en version 2.6.1.

La liste des nouvelles features ici :

Unity 2.6.1
Unity 2.6.1 contains a new webplayer plugin that is compatible with Mac OSX 10.6 Safari when running in 64-bit mode. Additionally a number of improvements and bug fixes were implemented to smooth out some of the issues experienced by Unity (free) license holders. Additionally, Unity 2.6.1 projects are now compatible with Unity iPhone 1.5.1 projects.
Improvements:

* The Mac webplayer has been rewritten to be compatible with 64-bit Safari on Mac OS X 10.6.
* Reduced time spent connecting to large Asset Server projects.

Editor Fixes:

* Fixed an editor crash when painting trees in the free version of Unity.
* Fixed an FBX import crash bug which could happen with some assets.
* Fixed rendering of terrain details in the editor after a player has been built.
* The Draw checkbox for trees and details in the terrain inspector now remembers it’s setting.
* Fixed ImportAssetOptions.ImportRecursive (it didn’t do anything before).
* Fixed a bug where the terrain lightmapper would render shadows incorrectly.
* Fixed an error message about asset timestamp counts that sometimes showed up after saving the project.
* Fixed warning when deleting a TerrainData asset which is used in the scene.
* Fixed a bug in which Input.GetMouseButton() would fail in the Editor on Windows, when the game view is detached from the main window.
* Fixed a bug where selecting text with the mouse would deselect the asset when renaming assets in the Project View.
* Fixed an Editor crash when pressing the gear menu on the default references of a script on Windows.
* Editor Search string now resets when objects not matching the search filter are selected.
* Unity will now highlight prefabs in Project view when selecting the prefab from the GameObject Inspector.
* Fixed an editor crash when trying to compare against a non existent asset in the Asset Server history view.
* Fixed an editor crash when passing an invalid prefab reference to EditorUtility.ReplacePrefab().

Runtime Fixes:

* Fixed a runtime crash when changing screen size or FSAA settings when RenderTexture assets are used.
* Fixed more than 2 Image Filters being upside down on Windows when Anti-Aliasing was used.
* Fix GUI toggles drawing with the wrong state when on.
* Fixed a regression which broke http://WWW.LoadImageIntoTexture() in some cases.
* Fixed AudioSoruce.ignoreListenerVolume to work again.
* Fixed a bug which could cause gamepad input to get lost on Windows when multiple gamepads are connected.

Upgrade Guide

Projects opened or created with Unity 2.6 are not backwards compatible with earlier Unity versions. Back up your project folders before opening them with 2.6 just in case.

When opening an existing project, Unity 2.6 will reimport all assets. This can take a long time for large projects.

* Texture assets need to be explicitly marked as « Readable » in order for GetPixel, SetPixel and other pixel manipulation functions to work. By default this flag is off, which saves a lot of memory at runtime. Set this flag on texture assets that need it. Textures created from scripts at runtime do not need this flag, they are readable automatically.
* Image Effects now work with Anti-Aliasing. In order for all of them to work however, you have to upgrade Pro Standard Assets package. If you’re using custom image effects, it’s advisable to use Graphics.Blit instead of drawing a fullscreen quad manually.
* Mouse move (EventType.MouseMove) UnityGUI events are not sent in the game anymore. You can get the same information using mouse delta in Repaint events.
* In previous versions of Unity, automatic texture format sometimes defaulted to DXT1 even if « Build Alpha from Grayscale » option was set. Now when that option is set, automatic compressed texture format is always DXT5. So some of your textures might get a real alpha channel now; if you don’t want that then uncheck the option or explicitly set format to DXT1.
* Image Effects behaviour with multiple layered cameras has changed. Now when there are multiple cameras (some of which do not clear the screen), Image Effects will be composited as logically expected. If you were relying on undefined or accidental behaviour in previous Unity version, you might have to change your camera and/or Image Effect setup.
* Building a Windows player using Editor APIs now takes path to the .exe file, not the enclosing folder. Your BuildPipeline or player post-processing scripts need to account for this.
* Some Editor API functions were changed or removed. Your Editor customization scripts might need update, especially if you were using undocumented APIs.

Merci à Steph3D pour l’info 😉

Unity 3D et la réalité augmentée

La réalité augmentée est effective sur Unity avec cette démo du site Robotduck. Le principe est de controller un jeu de voiture avec un volant imprimé sur une feuille et qui sert de marqueur à la caméra.

L’axe des Z est aussi repéré afin de produire l’accélération et le freinage. Le tout a été implémenté grâce à une dll spécifique pour la webcam et une version béta de UnityAR, un dérivé du très connu ARToolkit.

Voilà une intégration qui promet et que vous pouvez visionner ci-dessous.

UniDevelop : un éditeur de code

Si comme moi vous êtes habitués à coder avec l’excellent Flashdevelop, le studio Blurst (encore lui) a sortit il y a quelques temps déjà un éditeur basé sur ce dernier.

Son nom est UniDevelop et vous retrouverez toute l’ergonomie de Flashdevelop, comme l’arborescence des variables et fonctions, la gestion des fichiers projets, l’autocompletion etc.

Un indispensable à télécharger

Pack de scripts pour noobs

Pour tous les débutants sur Unity, Unity Spain propose un pack de scripts pour Unity 3D en 2 versions :

-une version light dans laquelle vous aurez un petit package

-une version advanced à 3$ qui contient des scripts plus évolués dont vous pouvez voir une démo. Je copie-colle le descriptif du contenu :

Advanced ScriptPack Contains 10 fully functional scripts commented in Spanish and English for better code understanding:

• Follow Player: this script make the enemy follow you, and, hurts your player if is in a certain distance

• Bidimensional Control in 3D:Similar to Bidimensional control in the noob
scriptpack, but the diference is the character rotates to the position that moves
when changes the direction that moves. ideal for 3D games with 2D gameplay

• Camera Movement:this is an RTS camera Script, you can move , zoom and rotate the camera.

• ClickandGo2: this is « the point and click » gameplay control script. ideal for RPGs and Graphic Adventures.

• Rocket Move: This script let you control the player like a spacecraft in 2D

• TridimensionalCharacterRotation:this script is an FPSwalker « ADDON » that makes the object look to the way that it moves.

• EmitPropulsor:This script emit particles and flick a light when you push certain button.

• Simple Arcade Title Screen: an arcade start menu script with flickering text (« pres start button » stile).

• Continous Collision-Instance: this scripts let you instantiate continuosly objects (sparks per example).

• DestroyOnCollide-Advanced: This script let you instantiate different types of objects when an object collides(decals, explosions, chunks, particles…). Ideal for all types of proyectiles and more.

Celà vous permettra de mieux comprendre la logique de Unity sans vous perdre sur des détails parfois perturbants.