TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Joshua Hecht
NA
8
2.8k
Why is my Unity Mathf.Lerp not working?
Jun 8 2017 5:18 PM
I'm trying to make a moving platform and I've set up a script that handles the lerp of the platform, but no matter what I do I can't get the darn thing to move. The method I set up is supposed to lerp a float which will be the x-axis of the transform.
using UnityEngine;
using System.Collections.Generic;
using System.Collections;
public class PlatformController : MonoBehaviour
{
float Output = 0;
float CurrentXPos;
void Start()
{
CurrentXPos = transform.position.x;
}
void Update()
{
Vector3 temp = new Vector3(PlatformMovement(), transform.position.y, transform.position.z);
transform.position = temp;
Debug.Log(Output);
}
float PlatformMovement()
{
float accumulator = .001f;
Output = Mathf.Lerp(CurrentXPos, 8f, accumulator);
accumulator += .05f; //Constant speed
return Output;
}
}
Reply
Answers (
1
)
ActionScript 3.0
how to auto screen roatate in html 5 or javascript