1. All Unity Pro perpetual license customers: your special offer to subscribe is ready! Click here.
  2. We're running a survey about the usage of our graphics pipeline, help give us your feedback.
  3. Unity 5.6 beta is now available for download.
  4. Unity 5.5 is now released.
  5. Check out all the fixes for 5.5 in patch releases 1 & 2.
  6. Enter the Google Play Indie Games Contest in Europe. Read more about it here.
  7. Get prepared for the Tizen Mobile App Incentive Program! Read more about the upcoming program here.
  8. Enter the Microsoft Developer Challenge for a chance to win prizes. Read more about it here.

Bouncy Breast Physics (NSFW?)

Discussion in 'Scripting' started by Fishypants, Sep 26, 2011.

  1. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Messages:
    442
    Hey everyone. So in response to a question asked in another topic, I came up with this system for having bones jiggle around based on a very crude / simple physics model. The physics part is a modified version of Pegorari's "Rubber Simulation Script" (http://forum.unity3d.com/threads/45148-Rubber-Simulation-Script?highlight=rubber+duck) but instead of modifying vertex positions, it applies the results to bone rotations. It also has a "squash and stretch" function, which helps to add a little bit of extra fluid motion.

    It can be used for effects like bouncy breasts, bouncy hair, etc. Hope you guys like. Also if anyone has any ideas on how to improve it, please contribute:

    The webplayer has settings set WAY too high. It's set that way for demonstration purposes only, and would have to be adjusted to more real world settings.

    Screenshot:
    [​IMG]

    Webplayer:
    http://www.mikecookportfolio.com/jiggleBone/jiggleBoneWeb.html

    And link to the Wiki:
    Jiggle Bone Unity Wiki
     
    Last edited: Sep 26, 2011
  2. vmp

    vmp

    Joined:
    Mar 13, 2006
    Messages:
    23
    i am working on a character that has jiggly fat. this could be ideal, i cant seem to view the web demo it just asks me to instal the unity player but the one it downloads is older than the one i have installed.

    nice share though

    Arthur
     
  3. scarpelius

    scarpelius

    Joined:
    Aug 19, 2007
    Messages:
    946
    Duke Nukem: Shake it baby!

    :), very nice example and thanks for the code.
     
  4. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Messages:
    2,347
    Awesome! I think ill play with this whole day :p
     
  5. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Messages:
    1,491
    I see a billion dollar app right there.
     
    TD10074405 likes this.
  6. NickChalvatzakis

    NickChalvatzakis

    Joined:
    Sep 19, 2011
    Messages:
    14
    I love it!!


    - pervert yes! -
     
  7. KHopcraft

    KHopcraft

    Joined:
    Jun 6, 2009
    Messages:
    3,248
    LOL.

    ... Indeed.
     
  8. XeviaN360

    XeviaN360

    Joined:
    Jun 3, 2010
    Messages:
    179
    U're a genius XD
     
  9. Kinos141

    Kinos141

    Joined:
    Jun 22, 2011
    Messages:
    968
    Good job, gooooooood job
     
  10. bigmisterb

    bigmisterb

    Joined:
    Nov 6, 2010
    Messages:
    4,067
    Great job, and thanks for sharing.. this is making my dream of a video game with nothing but REALLY fat people look all the better. :D
     
  11. Lemo Dev

    Lemo Dev

    Joined:
    Sep 9, 2011
    Messages:
    6
    Is it possible for you to upload the project so I can see how it all works together.

    Thanks
     
  12. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Messages:
    442
    @ Lemo

    Believe it or not, I have no idea where that project went . . . :T
    Its pretty straight forward, just drag the script onto a transform of the bone on your mesh. You will have to know what axis to shoot it down. For me I had the bone axis set to Z forward, meaning the Z axis was looking down the length of the bone. You can change which axis it uses in the script though so you can mess with the values.

    If you're still having problems just ask!
     
  13. ptdnet

    ptdnet

    Joined:
    Apr 20, 2011
    Messages:
    100
    Hmm... my game is a 2D platformer, but I simply MUST have this feature.

    Maybe the splash screen.
     
  14. miroku000

    miroku000

    Joined:
    Sep 12, 2010
    Messages:
    19
    Hi.

    So, I have a bunch of 3d models that are .FBX files from the asset store. I wanted to try this on them. But, they do not have any bones defined for inside the boobs. So, is it possible? Would I have to define new bones in a modeling program and somehow remap the mesh to them? Is there anyway to do this from within Unity (or if not through some plugin to unity?)

    Because none of the models I have currently has bones to control the boobs as far as I can tell.
     
  15. ptdnet

    ptdnet

    Joined:
    Apr 20, 2011
    Messages:
    100
    I absolutely approve this app.
     
  16. Bobbbbil

    Bobbbbil

    Joined:
    Jan 10, 2013
    Messages:
    49
    Nice job!
     
  17. TMPxyz

    TMPxyz

    Joined:
    Jul 20, 2012
    Messages:
    683
    Wow, thanks for the great job.
    And for those who have bones facing -X axis, I made some changes on your code so it works on standard 3dsmax export bones.

    Code (csharp):
    1. // Set bone rotation to look at dynamicPos
    2. //transform.LookAt(dynamicPos, upVector);
    3. Vector3 negXAxis = (dynamicPos - transform.position).normalized;
    4. Vector3 negZAxis = Vector3.Cross(negXAxis, upVector); // -Z = -X cross oldup
    5. Vector3 newUp = Vector3.Cross (negZAxis, negXAxis); // Y = -Z cross -X
    6. transform.LookAt(transform.position + (-negZAxis), newUp );
     
    theANMATOR2b likes this.
  18. Vance Walsh

    Vance Walsh

    Joined:
    Apr 9, 2013
    Messages:
    1
    So I'm using this and trying to get the workflow down with makehuman to blender to unity. I'm almost there, but for some reason, even with the adjustments TMPxyz added I still have bones that seem to want to point out from straight. As if they are being pushed apart (rotated on the vertical axis) away from each other by about 15 degrees each. This makes a nice separate on some models but on my current one, it would be nice to make them seem a little more 'perky and straight'.

    Does anyone have tips for Blender rigging and importing to unity? I'm able to use the humanoid rig setup in unity and I do get the bounce effect, however the axis are definitely off and all of my tests have come up with inverted meshes. The only current way it works is to have all axis set to 0.

    Thanks for this however, since I'm sure its just something simple I am not seeing yet. It really is very configurable.

    EDIT ---

    So I found out that my export settings, or some other setting isn't allowing the bone in blender to face the 'right' way, so I had to go by the transform gizmo and a lot of guesswork to get it to the right angle. Once I was able to get it to face forward (z) and have y up the original script worked great.

    Pro Tip: position the bones where you want the rotation to be based out of. For a while I had my bones outside the mesh (so they were easy to grab) but I soon found my deformation in unity rotation oddly outside the 'mesh body'. Now the extra jiggle control bones are back inside the mesh and it rotates / squishes properly!
     
    Last edited: May 29, 2013
  19. Jtbentley_v2

    Jtbentley_v2

    Joined:
    Sep 5, 2012
    Messages:
    174
    This is the greatest Unity application ever made.
     
  20. trooper

    trooper

    Joined:
    Aug 21, 2009
    Messages:
    637
  21. Tinker92

    Tinker92

    Joined:
    Jan 23, 2013
    Messages:
    1
    I just discovered this not to long ago and at the moment I'm playing with this. i was having some trouble with it screwing up my mesh.
    the bone rotation was all over the place.... (I think imported that way.) or because of this code.
    Code (csharp):
    1.  // Set bone rotation to look at dynamicPos
    2.         transform.LookAt(dynamicPos, upVector);
    3.  
    And since I'm a newb and am clueless as to figure out the problem with that code so i ended up writing a line to give control of the rotation of the bones. i haven't fully tested to see if messing around with the rotation kills the jiggle action. its shouldn't really considering my bone rotation was completely out of wack and they were still jiggling. but I'll test, and get back to it.

    Code (csharp):
    1.  
    2. // set the bone rotation
    3.         transform.localRotation = new Quaternion (boneAxis.X, boneAxis.Y, boneAxiz.Z, 0.0f);
    4.  
    5.  
     
    Last edited: Jun 19, 2013
  22. SunnySunshine

    SunnySunshine

    Joined:
    May 18, 2009
    Messages:
    554
    Recently I noticed the items using jiggle bone in my application had started behaving oddly, as if there was little or no effect applied at all. As I hadn't changed anything in my project, this puzzled me. After some testing, I realized this had to do with my new monitor. Before I had a 60 Hz one, and my new one is 144Hz. It appears that jiggle bone does not take time into account when making its calculations, making it frame dependent, which is very bad. Also, time scale does not seem to affect it, which is also bad.

    The changes needed to fix this is a bit over my head, but if anyone could take a look at this it would be awesome. Probably just a couple of multiplications with deltatime and timescale.
     
    Last edited: Jun 28, 2013
  23. uncle TIN

    uncle TIN

    Joined:
    Nov 3, 2012
    Messages:
    15
    seem not work in max fbx export
     
  24. Atmey

    Atmey

    Joined:
    Nov 3, 2012
    Messages:
    88
    Many thanks, my blender export had issues, Z axis pointing to the left, X axis pointing to the front and the other side to the back. I used your script and adjusted the original UP value and it works pretty good.
     
  25. IainDaddy

    IainDaddy

    Joined:
    May 29, 2013
    Messages:
    9
    I always said that the best inventions on the internet were driven by sex.

    This code has so many applications ... and I will tell you some once I have finished tweaking the Y axis.

    Why was this not part of Tomb Raider?

    All the best.

    Iain
     
    Last edited: Jul 21, 2013
  26. Atmey

    Atmey

    Joined:
    Nov 3, 2012
    Messages:
    88
    I think it was on some Tomb Raider games but very slight, you have to look for it to notice it.

    Anyway, I still having some problems, it was working fine but when I rotated the whole character it got weird again, can't we retrieve the axes and compare it to the world and apply UP and gravity correctly?

    I'll try to study/understand the code further.
     
  27. Atmey

    Atmey

    Joined:
    Nov 3, 2012
    Messages:
    88
    I failed to retrieve and set the rotation automatically, I added extra parameters, increment the rotation by 90s, trial and error works fine.

    Code (csharp):
    1. //  ============================================================
    2. //  Name:       Jiggle Bone v.1.0
    3. //  Author:     Michael Cook (Fishypants)
    4. //  Edited by:  Atmey
    5. //  Date:       9-3-2013
    6. //  License:    Free to use. Any credit would be nice :)
    7. //
    8. //  To Use:
    9. //      Drag this script onto a bone. (ideally bones at the end)
    10. //      Set the boneAxis to be the front facing axis of the bone.
    11. //      Done! Now you have bones with jiggle dynamics.
    12. //
    13. //  ============================================================
    14.  
    15. using UnityEngine;
    16. using System.Collections;
    17.  
    18. public class jiggleBone : MonoBehaviour {
    19.     public bool debugMode = true;
    20.  
    21.     // Target and dynamic positions
    22.     Vector3 targetPos = new Vector3();
    23.     Vector3 dynamicPos = new Vector3();
    24.  
    25.     // Bone settings
    26.     public Vector3 boneAxis = new Vector3(0,0,1);
    27.     public float targetDistance = 2.0f;
    28.     public Vector3 upDirection = new Vector3(0,1,0);
    29.     public Vector3 extraRotation = new Vector3(0,0,0);
    30.  
    31.     // Dynamics settings
    32.     public float bStiffness = 0.1f;
    33.     public float bMass = 0.9f;
    34.     public float bDamping = 0.75f;
    35.     public float bGravity = 0.75f;
    36.  
    37.     // Dynamics variables
    38.     Vector3 force = new Vector3();
    39.     Vector3 acc = new Vector3();
    40.     Vector3 vel = new Vector3();
    41.  
    42.     // Squash and stretch variables
    43.     public bool SquashAndStretch = true;
    44.     public float sideStretch = 0.15f;
    45.     public float frontStretch = 0.2f;
    46.  
    47.     void Awake(){
    48.         // Set targetPos and dynamicPos at startup
    49.         Vector3 targetPos = transform.position + transform.TransformDirection(new Vector3((boneAxis.x * targetDistance),(boneAxis.y * targetDistance),(boneAxis.z * targetDistance)));
    50.         dynamicPos = targetPos;    
    51.        
    52.     }
    53.  
    54.     void LateUpdate(){
    55.         // Reset the bone rotation so we can recalculate the upVector and forwardVector
    56.         transform.rotation = new Quaternion();
    57.         //transform.localRotation = originalQuat;
    58.  
    59.         // Update forwardVector and upVector
    60.         Vector3 forwardVector = transform.TransformDirection(new Vector3((boneAxis.x * targetDistance),(boneAxis.y * targetDistance),(boneAxis.z * targetDistance)));
    61.         Vector3 upVector = transform.TransformDirection(upDirection);
    62.         //upVector = upDirection;
    63.  
    64.         // Calculate target position
    65.         Vector3 targetPos = transform.position + transform.TransformDirection(new Vector3((boneAxis.x * targetDistance),(boneAxis.y * targetDistance),(boneAxis.z * targetDistance)));
    66.  
    67.         // Calculate force, acceleration, and velocity per X, Y and Z
    68.         force.x = (targetPos.x - dynamicPos.x) * bStiffness;
    69.         acc.x = force.x / bMass;
    70.         vel.x += acc.x * (1 - bDamping);
    71.  
    72.         force.y = (targetPos.y - dynamicPos.y) * bStiffness;
    73.         force.y -= bGravity / 10; // Add some gravity
    74.         acc.y = force.y / bMass;
    75.         vel.y += acc.y * (1 - bDamping);
    76.  
    77.         force.z = (targetPos.z - dynamicPos.z) * bStiffness;
    78.         acc.z = force.z / bMass;
    79.         vel.z += acc.z * (1 - bDamping);
    80.  
    81.         // Update dynamic postion
    82.         dynamicPos += vel + force;
    83.  
    84.         // Set bone rotation to look at dynamicPos     
    85.         transform.LookAt(dynamicPos, upVector);
    86.    
    87.         //Apply extra rotation
    88.         transform.Rotate(extraRotation,Space.Self);    
    89.        
    90.  
    91.         // ==================================================
    92.         // Squash and Stretch section
    93.         // ==================================================
    94.         if(SquashAndStretch){
    95.             // Create a vector from target position to dynamic position
    96.             // We will measure the magnitude of the vector to determine
    97.             // how much squash and stretch we will apply
    98.             Vector3 dynamicVec = dynamicPos - targetPos;
    99.  
    100.             // Get the magnitude of the vector
    101.             float stretchMag = dynamicVec.magnitude;
    102.  
    103.             // Here we determine the amount of squash and stretch based on stretchMag
    104.             // and the direction the Bone Axis is pointed in. Ideally there should be
    105.             // a vector with two values at 0 and one at 1. Like Vector3(0,0,1)
    106.             // for the 0 values, we assume those are the sides, and 1 is the direction
    107.             // the bone is facing
    108.             float xStretch;
    109.             float yStretch;
    110.             float zStretch;
    111.             if(boneAxis.x == 0) xStretch = 1 + (-stretchMag * sideStretch);
    112.             else xStretch = 1 + (stretchMag * frontStretch);
    113.  
    114.            
    115.             if(boneAxis.y == 0) yStretch = 1 + (-stretchMag * sideStretch);
    116.             else yStretch = 1 + (stretchMag * frontStretch);
    117.  
    118.            
    119.             if(boneAxis.z == 0) zStretch = 1 + (-stretchMag * sideStretch);
    120.             else zStretch = 1 + (stretchMag * frontStretch);
    121.  
    122.             // Set the bone scale
    123.             transform.localScale = new Vector3(xStretch, yStretch, zStretch);
    124.         }
    125.  
    126.         // ==================================================
    127.         // DEBUG VISUALIZATION
    128.         // ==================================================
    129.         // Green line is the bone's local up vector
    130.         // Blue line is the bone's local foward vector
    131.         // Yellow line is the target postion
    132.         // Red line is the dynamic postion
    133.         if(debugMode){
    134.             Debug.DrawRay(transform.position, forwardVector, Color.blue);
    135.             Debug.DrawRay(transform.position, upVector, Color.green);
    136.             Debug.DrawRay(targetPos, Vector3.up * 0.2f, Color.yellow);
    137.             Debug.DrawRay(dynamicPos, Vector3.up * 0.2f, Color.red);
    138.         }
    139.         // ==================================================
    140.     }
    141. }
     
  28. D.Coy

    D.Coy

    Joined:
    Jun 2, 2013
    Messages:
    3
    Anyone have any luck using this (brilliant) script with fbx exports from Maya?
    Z forward, Y up isnt working and, it seems, no matter which way I orient the bones Im getting pretty narly results. It looks like the script is twisting the bones 90 degrees to the right of the character, but reorienting them to counter doesnt fix it.
    C# is pretty foreign to me, so Im perhaps failing to see something in the script.

    I have gotten better results using Atmeys update, but the gravities is still wrong and not getting anything like the results in the webplayer.
    Any tips?
     
  29. leebs0117

    leebs0117

    Joined:
    Jul 1, 2013
    Messages:
    5
    My bone is facing -x, I use TMPxyz 's code but not get luck,
    I found the bone facing -x should use -x as forward(not z) and lookat "dynamicPos",
    so I should't use
    Code (csharp):
    1.  
    2.  transform.LookAt(...)  
    3.  
    I use custom lookat matrix to make my bone's x axis as forward

    Code (csharp):
    1.  
    2.     //由 X 當 forward 的 lookat.
    3.     static public Matrix4x4 LookAtFromX(Vector3 eye, Vector3 target, Vector3 up)
    4.     {
    5.         //http://games.greggman.com/game/webgl-3d-cameras/
    6.         //http://3dgep.com/?p=1700#The_View_Matrix
    7.         //http://msdn.microsoft.com/en-us/library/windows/desktop/bb281710(v=vs.85).aspx
    8.  
    9.         Vector3 vx = eye - target; // The "forward".
    10.         vx.Normalize();
    11.         Vector3 vz = Vector3.Cross(up, vx);// The "right" .
    12.         // vy doesn't need to be normalized because it's a cross
    13.         // product of 2 normalized vectors
    14.         Vector3 vy = Vector3.Cross(vz, vx);// The "up".
    15.         Matrix4x4 inverseViewMatrix = new Matrix4x4();
    16.        
    17.         inverseViewMatrix.SetColumn(0, new Vector4(vx.x, vx.y, vx.z , 0));//
    18.         inverseViewMatrix.SetColumn(1, new Vector4(vy.x, vy.y, vy.z , 0));//
    19.         inverseViewMatrix.SetColumn(2, new Vector4(vz.x, vz.y, vz.z , 0));//用 right 當 forward.
    20.         //inverseViewMatrix.SetColumn(3, new Vector4(-Vector3.Dot(vx, eye), -Vector3.Dot(vy, eye), -Vector3.Dot(vz, eye) , 1));
    21.         inverseViewMatrix.SetColumn(3, new Vector4(eye.x, eye.y, eye.z , 1));
    22.        
    23.         return inverseViewMatrix.inverse;
    24.     }
    25.  
    then , I get quaternion from the matrix.

    Code (csharp):
    1.  
    2.     //由 matrix 中 取出 quaternion.
    3.     static public Quaternion QuaternionFromMatrix(Matrix4x4 m)
    4.     {
    5.         // Adapted from: http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm
    6.         Quaternion q = new Quaternion();
    7.         q.w = Mathf.Sqrt( Mathf.Max( 0, 1 + m[0,0] + m[1,1] + m[2,2] ) ) / 2;
    8.         q.x = Mathf.Sqrt( Mathf.Max( 0, 1 + m[0,0] - m[1,1] - m[2,2] ) ) / 2;
    9.         q.y = Mathf.Sqrt( Mathf.Max( 0, 1 - m[0,0] + m[1,1] - m[2,2] ) ) / 2;
    10.         q.z = Mathf.Sqrt( Mathf.Max( 0, 1 - m[0,0] - m[1,1] + m[2,2] ) ) / 2;
    11.         q.x *= Mathf.Sign( q.x * ( m[2,1] - m[1,2] ) );
    12.         q.y *= Mathf.Sign( q.y * ( m[0,2] - m[2,0] ) );
    13.         q.z *= Mathf.Sign( q.z * ( m[1,0] - m[0,1] ) );
    14.         return q;
    15.     }
    16.  
    final code

    Code (csharp):
    1.  
    2.         Matrix4x4 lax = LookAtFromX(transform.position, dynamicPos, Vector3.up);       
    3.         transform.rotation = QuaternionFromMatrix(lax);
    4.  
    now my girls breasts works great!! :)
     
  30. raeldor

    raeldor

    Joined:
    Jul 8, 2013
    Messages:
    39
    Hi,

    This script looks great, but when I try to attach it to my object the boob seems to be somewhat rotated and out of alignment. I think it may be something to do with the default rotation of the bone. When I look character head-on with the bone selected in translate mode, the y seems to be pointing downwards, and the x seems to be point diagonally towards me at about (approx) 45 degrees to the right, and the pointing towards me to the left at about 45 degrees.

    Would this adversely affect the script? Is there any way to adjust the script to take this into account?

    Thanks
    Ray
     
  31. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Messages:
    442
    @raeldor - yeah that will definitely effect the script. It might be possible to try and plot out the correct offset, but you will honestly have a much easier time if the model is rigged correctly to begin with.
     
  32. raeldor

    raeldor

    Joined:
    Jul 8, 2013
    Messages:
    39
    Appreciate the response, thank you. The model is exported from Autodesk Character Creator, so I may try and tweak the script so I don't have to do a manual adjustment every time I export.

    Many Thanks
     
  33. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Messages:
    4,567
    Have you all seen this one?
    Looks successful to me... I don't have any need for it in my games, but if I did, I'd certainly study this example.
     
    rakkarage and Stoven like this.
  34. raeldor

    raeldor

    Joined:
    Jul 8, 2013
    Messages:
    39
    So I'm looking at the code, but having a hard time getting my head around this one. It seems that my bone's 'up' is not a standard (0,1,0), so I tried putting this into awake()...

    originalUp = transform.up;

    And then in LateUpdate() I put...

    transform.LookAt(dynamicPos, originalUp);

    But this results in a boob that bounces to the side, though interestingly doesn't have the 'twistedness' it did when using upVector (which is 0,1,0 btw).

    Thanks
    Ray
     
  35. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Messages:
    442
    @joe - Yeah that method is ok, but the problem is its kind of like a chase cam, it will lag behind but never follow through with the momentum of the breasts. I guess it depends on what you're going for aesthetic-wise.

    @raeldor - Its hard to diagnose what the issue could be, without seeing the scene file and the joint orientations. I've been meaning to take another crack at the script since it has been a while since I've looked at it and chances are things could be done better / differently. If I have free time I will try to take a look at it again.
     
  36. raeldor

    raeldor

    Joined:
    Jul 8, 2013
    Messages:
    39
    When I turn on debug (rays) I think the problem seems to be that the target is being manipulated in world space co-ordinates, whereas because the original rotation where the breast is at rest (hey, I'm a poet!) is not identity it's resulting in the bounce being in the wrong direction. Is there a way I could rotate the vel+force to be oriented in the correct direction before adding to the dynamicpos? Or maybe it's not that simple, since it re-uses the value of dynamicpos next iteration?

    Thanks
     
    Last edited: Sep 6, 2014
  37. raeldor

    raeldor

    Joined:
    Jul 8, 2013
    Messages:
    39
    I think I have it working. I need to do more testing, but I put this in the awake()...

    originalRotation = transform.rotation;

    And then in the lateupdate() I put...

    transform.LookAt (dynamicPos);
    transform.Rotate(originalRotation.eulerAngles, Space.Self);

    I'll do some more testing to see if they behave 'naturally'. :p
     
  38. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Messages:
    114
    Anyone still have the original version of this script?

    How about a project file demonstrating it in action for us newbs to study?
     
  39. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Messages:
    442
  40. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Messages:
    114
    Lol, yep. Thanks. ;P

    I must've missed that link... because, y'know.... boobs.
     
    theANMATOR2b likes this.
  41. LoungeKatt

    LoungeKatt

    Joined:
    Mar 4, 2014
    Messages:
    35
    I know this post is a bit old, but I stumbled across this looking for something for a DOA style fighting game.

    The models are saved .blend files from blender, which you may know means they are inverse and backwards compared to Unity but by taking the original script and replacing

    Code (CSharp):
    1. // Set bone rotation to look at dynamicPos
    2. transform.LookAt(dynamicPos, upVector);
    with
    Code (CSharp):
    1. transform.localRotation = newQuaternion (boneAxis.x, boneAxis.y, boneAxis.z, 0.0f);
    it did fix the issue and did not require that I go through and guess values (like i did the first half hour) or perform some nuclear physics type of matrix calculation (like I feared from an earlier post)
     
  42. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Messages:
    290
  43. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Messages:
    442
    @TerraUnity

    Thats so cool! Congrats on the project, it looks amazing! Cheers!
     
    TerraUnity likes this.
  44. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Messages:
    290
    Thanks for the compliment. Hope you don't mind that we used it for purposes other than the OP :)
     
  45. ethanwgross

    ethanwgross

    Joined:
    Jun 25, 2014
    Messages:
    36
    @Fishypants
    Hey man, bravo for that wonderful contribution of brilliant code. I learned a great deal from it and plan to use it in an upcoming project. Will certainly give due credit for this. Thanks again.
     
  46. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Messages:
    442
    @ethanwgross - Cool man, glad it's getting put to use! Cheers!