Hi, i want to change the speed variable of Vector3.Slerp but when i do it, it changes the position because there is a transform.
Tried:
1- If you change the number only when the game start, it works perfectly.
2- I was trying to save the variable just a moment before changing the speed and apply it to the position, but it seems it doesn’t work or it do weird things.
The thing i want to get
Changing the Vector3.Slerp velocity without changing the position.
FIRST CODE WITHOUT CHANGING ANYTHING:
Code:
var TimeSpeed : float = 1;
var Sun : GameObject;
var sunrise : GameObject;
var sunset : GameObject;
var center = (sunrise.position + sunset.position) * 0.5;
// move the center a bit downwards to make the arc vertical
center -= Vector3(0,0.1,0);
// Interpolate over the arc relative to center
var riseRelCenter = GeneralSettings.Helpers.sunrise.position - center;
var setRelCenter = GeneralSettings.Helpers.sunset.position - center;
fracComplete = fracComplete*TimeSpeed;
Sun.transform.position =
Vector3.Slerp(riseRelCenter, setRelCenter, fracComplete);
LightSettings.Sun.transform.position += center;
SECOND CODE MODIFIED:
var TimeSpeed : float = 1;
var Sun : GameObject;
var sunrise : GameObject;
var sunset : GameObject;
var center = (sunrise.position + sunset.position) * 0.5;
// move the center a bit downwards to make the arc vertical
center -= Vector3(0,0.1,0);
// Interpolate over the arc relative to center
var riseRelCenter = GeneralSettings.Helpers.sunrise.position - center;
var setRelCenter = GeneralSettings.Helpers.sunset.position - center;
fracComplete = fracComplete*TimeSpeed;
Sun.transform.position =
Vector3.Slerp(riseRelCenter, setRelCenter, fracComplete);
LightSettings.Sun.transform.position += center;
if(timeSpeed2 == !ActualTimeGame.timeSpeed && change2 == true){
print("Bien hasta aquí");
fracComplete = fracComplete*ActualTimeGame.timeSpeed;
LightSettings.Sun.transform.position = Vector3.Slerp(riseRelCenter, setRelCenter, fracComplete);
LightSettings.Sun.transform.position += center;
}
frac2 = fracComplete;
if(ActualTimeGame.timeSpeed != timeSpeed2){
frac = fracComplete;
return;
if(!oneTimeFrac){
oneTimeFrac = true;
timeSpeed2 = ActualTimeGame.timeSpeed;
change= true;
fracComplete = frac;
change2=true;
}
Thanks in advance, KirbyRawr.
PD: the codes can contain some errors.