I have been throwing my head at this problem for a long time, and I am at the top, not understanding this.
Problem:
Currently trying to make a fake "swing" moment. When I have a player object that becomes a child object that you can snap during the keyboard.
With that in mind, I need to get the correct rotation in grappleobject by making the player speed the correct rotation in grappleobject.
This should not be 2D, but 3D. It causes a headache.
http://img843.imageshack.us/img843/7434/rotations.jpg
I thought that if I could get the position vector and the direction vector where the player is going, as well as the speed of the characterโs engine, get a unique Vector, and this vector information should be able to correctly rotate the graft block.
However, this is what I thought was easy, but I cracked it several times to get this difference in vectors, to make a turn, as it was thought.
TL: dr
2 Vectors, the difference of these two by one vector, this vector controls the rotation of the grapple-like object to "fake" the oscillatory motion at the proper speed.
Thanks in advance if there will be an answer.
Information added:
Current tests were like that.
///
Parent Orb is a grappleobjects that updates its conversion depending on trigger events.
CurDirection is where the player moves inside the vector in the world.
CurPos is where the player is at that moment in time in the world.
CurDirection = (transform.position-ParentOrb.position); CurDirection.Normalize(); motor.movement.velocity = (CurDirection); CurPos = transform.position;
////
Also tried to get the angle from grappleobject to the player.
///
otherDirection = direction of speed in space.
OtherDirectionPre = Current position in space.
Vector3 targetDir = otherDirection; Vector3 forward = otherDirectionPre; angle = Vector3.Angle(targetDir, forward);
/// I suppose this may not be very useful, but itโs better to show where I am so far.