- Home /
Question by
Matt 28 · May 01, 2011 at 07:55 AM ·
spritemanager2
Playing Different Sprite Animations in a Vector3 setup.
Was using this nice movement script-
using UnityEngine; using System.Collections;
public class Movement25 : MonoBehaviour {
public PackedSprite playerSprite;
public float jumpStrength = 5f;
public float stepSpeed = 5f;
public float gravity = 9.8f;
public float mass = 1f;
private Vector3 targetDirection = Vector3.zero;
private CharacterController controller;
void FixedUpdate()
{
controller = this.GetComponent<CharacterController>();
if (controller.isGrounded)
{
targetDirection.x = Input.GetAxis("Horizontal") * stepSpeed;
targetDirection.z = Input.GetAxis("Vertical") * stepSpeed;
if (Input.GetButton("Jump")) targetDirection.y = jumpStrength;
}
if (!controller.isGrounded) targetDirection.y -= gravity * mass * Time.deltaTime;
controller.Move(targetDirection * Time.deltaTime);
}
}
...and I have it attached to a sprite I created in SpriteManager2
Here in lies the problem.
How do you call different packed sprite animations in this script.
Example:
If the character is moving on the X axis, how would I tell the "playerSprite" to change from his static sprite to the walkright cycle animation or walkleft cycle animation I have created in Sprite Manager 2
Comment