# playMaker

### Author Topic: How do i convert this script in playmaker nodes  (Read 1288 times)

#### Abhishekrazy

• Playmaker Newbie
• Posts: 3
##### How do i convert this script in playmaker nodes
« on: August 24, 2015, 12:09:19 PM »
I only want to rotate my camera along the movable object with swipe rotation if this is possible please help me

I spend lot of time to make my camera rotate along the object but not succeed so finally i got this script.

i dont know what this script accully does.

var target : Transform;
var distance = 2.0;

var xSpeed = 180.0;
var ySpeed = 90.0;

var yMinLimit = 0.0;
var yMaxLimit = 80;

var speed : float = 0.14;

private var x = 0.0;
private var y = 0.0;

function Start () {
var angles = transform.eulerAngles;
x = angles.y;
y = angles.x;

// Make the rigid body not change rotation
if (rigidbody)
rigidbody.freezeRotation = true;
}

function LateUpdate () {

if (target && Input.GetMouseButton(0)) {
x += Input.GetAxis("Mouse X") * xSpeed * 0.02;
y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02;

y = ClampAngle(y, yMinLimit, yMaxLimit);

var rotation = Quaternion.Euler(y, x, 0);
var position = rotation * Vector3(0.0, 0.0, -distance) + target.position;

transform.rotation = rotation;
transform.position = position;
}

}

static function ClampAngle (angle : float, min : float, max : float) {
if (angle < -360)
angle += 360;
if (angle > 360)
angle -= 360;
return Mathf.Clamp (angle, min, max);
}

function Update () {

transform.LookAt(target);

transform.position -= transform.right * speed * Time.deltaTime;

if (Input.GetMouseButton(0)) {
transform.LookAt(target);
transform.RotateAround(target.position, Vector3.up, Input.GetAxis("Mouse X")*speed);
}

}
Abhishek razy

#### jeanfabre

• Hero Member
• Posts: 13323
• Official Playmaker Support
##### Re: How do i convert this script in playmaker nodes
« Reply #1 on: August 25, 2015, 10:59:50 AM »
Hi,

Give me a good week, and I'll turn this into a proper sample and I'll put it on the ecosystem, Please bump me mid next week ok? thanks

Bye,

Jean