kondor
1
HI
In this days Im learning C#
and a lot of time a go I wrote this code from a tutorial of pong creation:
var cSpeed : float = 10.0;
var sFactor : float = 10.0;
function Start()
{
rigidbody.AddForce(20,0,0);
}
function Update()
{
var cvel = rigidbody.velocity;
var tvel = cvel.normalized * cSpeed;
rigidbody.velocity = Vector3.Lerp(cvel,tvel,Time.deltaTime*sFactor);
}
and I wanted to ask how it will look like in C#?
and if can u explain on the “vector3.lerp” thing
thx for the help
using UnityEngine;
using System.Collections;
public class Player : MonoBehaviour
{
float cSpeed = 10.0f;
float sFactor = 10.0f;
void Start()
{
rigidbody.AddForce(20f, 0f, 0f);
}
void Update()
{
Vector3 cvel = rigidbody.velocity;
Vector3 tvel = cvel.normalized * cSpeed;
rigidbody.velocity = Vector3.Lerp(cvel, tvel, Time.deltaTime * sFactor);
}
}