Posts: 2
Threads: 1
Joined: Apr 2014
Hello guys. I am having a scene with a 2d sprite where i am creating dynamically a CatmulRom curve.Everything is just fine except the sprite orientation.So when i start creating the curve from the front side of the sprite where the sprite up vector is, it moves and orients just as it suppose to, but when i start creating the curve from the other side the sprite moves just fine, but comes out flipped in the opposite direction of the curve's tangents.I am moving and rotating on the same principle exposed in SpriteWalkerDistance.I am using as i said a CatmulRom curve with Orientation set to tangents, No CP rotation, Initial Up Vector - Control points.Can you help me understand what is happening?Thank you in advance
Posts: 690
Threads: 71
Joined: Jan 2015
Could you provide some screenshots or an example scene please?
Posts: 2
Threads: 1
Joined: Apr 2014
https://www.dropbox.com/s/xub29ffglrvvlac/curvy1.jpg
https://www.dropbox.com/s/0hx5vm3ngu7bzrv/curvy2.jpg
You can see on the second picture how the sprite starts moving flipped.This is when i start drawing spline behind its tail.
Posts: 690
Threads: 71
Joined: Jan 2015
04-08-2014, 06:36 AM
(This post was last modified: 04-08-2014, 06:36 AM by Jake.)
Ok, looks like the tangents flip once you add CPs behind the sprite, right? I can't think of a way this could happen unless you flip the spline's direction, but I'm sure we can sort this out. How do you exactly add new CPs?
Is it possible to export this behaviour as an example scene (either posting it here or by mail to jake (at) fluffyunderware (dot) com)?
Posts: 690
Threads: 71
Joined: Jan 2015
04-08-2014, 01:51 PM
(This post was last modified: 04-08-2014, 01:52 PM by Jake.)
Problem solved by mail:
The easiest way to orient a 2D sprite to a spline path is
Code:
transform.rotation = Quaternion.LookRotation(Vector3.forward,spline.GetTangentFast(tf));
Jake