LouiZeForum

3D vrml
 
HomeHome  FAQFAQ  SearchSearch  RegisterRegister  MemberlistMemberlist  UsergroupsUsergroups  Log in  3Dchats / forums3Dchats / forums  

Share | 
 

 smartfox scripts unity 3d

View previous topic View next topic Go down 
Go to page : Previous  1, 2, 3
AuthorMessage
alain
fondateur
fondateur
avatar

Number of posts : 23124
Localisation : Dompierre sur Veyle ,France
Registration date : 2005-04-19

PostSubject: Re: smartfox scripts unity 3d   Tue 24 Jul - 10:15

je cherchais comment faire EXAMINE, comme dans le vrml ..

Trouvé sur forum unity "orbit camera",
faut laisser le clic gauche appuyé et choisir une target




Code:


var target : Transform; //What to rotate around
var xSpeed : float = 125.0; //X sensitivity
var ySpeed : float = 50.0; //Y sensitivity

var resetTime : float = 1.0; //How long to take to reset

private var startDirection : Vector3 = Vector3.zero; //How far away to orbit

private var x : float = 0.0; //Y rotation
private var y : float = 0.0; //X rotation

private var endX : float = 0.0; //Where to reset x from
private var endY : float = 0.0; //Where to reset y from

private var startRotation : Quaternion; //Start orientation
private var rotation : Quaternion; //Current orientation

private var resetting : boolean = false; //resetting?
private var resetTimer : float = 0.0; //How long we've been resetting

@script AddComponentMenu("Camera-Control/Mouse Orbit and reset") //Add to menu

function LateUpdate() { //Every frame, do this as late as you can
    if (target) {//There's a target
        if(!resetting && Input.GetMouseButtonUp(0)) { //Released mouse button
            resetting = true;
            endX = x;
            endY = y;
            resetTimer = 0.0; //Reset the reset timer
        }

        if(!resetting) {
            if (Input.GetMouseButtonDown(0)) { //Pushed mouse button
                //Initialize
                startDirection = (transform.position - target.position);
                startRotation = transform.rotation;
                x = 0.0;
                y = 0.0;
            } //first time the button down

            if(Input.GetMouseButton(0)) { //Mouse button is down
                //Change the angles by the mouse movement
                x += Input.GetAxis("Mouse X") * xSpeed * 0.02;
                y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02;
                Reorient();
            } //button held down
        } //Camera moving
        else { //Reset
            resetTimer += Time.deltaTime; //add to the timer;
            var amountReset = resetTimer / resetTime; //How far we are
            x = Mathf.LerpAngle(endX, 0.0, amountReset); //Smooth angles
            y = Mathf.LerpAngle(endY, 0.0, amountReset); //Smooth angles
            Reorient();
            if(resetTimer >= resetTime) resetting = false;
        } //Reset
    } //There's a target
} //LateUpdate

function Reorient() { //orient yourself
    //Get the orientation and reorient
    rotation = Quaternion.Euler(y, x, 0);
    transform.rotation = rotation * startRotation;

    //Move the camera to that orientation
    transform.position = rotation * startDirection + target.position;
}





http://answers.unity3d.com/questions/25965/camera-orbit-on-mouse-drag.html

_________________
http://mixed3d.net/
Back to top Go down
View user profile
 
smartfox scripts unity 3d
View previous topic View next topic Back to top 
Page 3 of 3Go to page : Previous  1, 2, 3
 Similar topics
-
» [JOB] Recherche Développeur soft Unity
» Solus [RMXP]
» GEOPOLE Présentation
» [Résolu] Internet explorer 9
» Tous les script possible ne s'affiche pas!

Permissions in this forum:You cannot reply to topics in this forum
LouiZeForum :: ARTS :: 3D art :: unity 3d-
Jump to: