TSTransform2D move forward/face towards solutions? (Homing Missile)

So I need to make a homing missile, but I'm using the 2d engine, since the 3d one behaves strangely with my 2d project when freezing axes and unfortunately I can't mix the two like with the base Unity physics.

Is it possible to accomplish?


  • Wheathn
    edited March 2017
    Ah nvm, found a setting that made the 3d physics work fine. It was freezing the axes which was causing problems.
  • Good @Wheathn, congrats.
  • Yeah, though there's another problem I just found with the 3d physics that I'm having trouble working around. If I change the layer of or make the player a trigger to make him fall through a platform and the player is standing still, it will stay collided until the player moves a certain amount.

    I've tried flicking the isKinematic (does nothing), moving it past the platform by giving it a new tsTransform.pos (it snaps back after the layer or trigger changes back), adding a downward force (it just digs slightly into the platform)
  • Best workaround I found so far was to separate the physics (Sphere) collider as a different GameObject from everything else and set everything else to match its position. This way nothing goes spinning out of control.
    Then, when I hit "S" to drop through the platform, I change the layer, give it a small downward force, and set the angular velocity to (99,99,99).
    Really wish there were a simpler way lol.
  • Hi @Wheathn, this is a little bit complicated, when you have time can you send a simple project with a repro case of this issue? Thanks.
  • My first time using github, hope I did this correctly: https://github.com/Wheathn/CollisionStickSample
  • Thanks @Wheathn!!
  • Update: The 3d physics are still too messy for me. I was having random collision fails and desyncs. Switching back to 2d.

    Though now I'm at my original problem. How do I make a homing projectile without tsTransform.right?
    if (closestTarget == true) { if (!closestTarget.GetComponentInParent<XController> ().invis) { dir = closestTarget.GetComponentInParent<TSTransform> ().position - tsTransform.position; dir.Normalize (); FP value = TSVector.Cross (dir, tsTransform.right).z; tsRigidBody.angularVelocity = new TSVector (0, 0, -turnSpeed * value); tsRigidBody.velocity = tsTransform.right * missileSpeed; } }

    That's what I'm using for the 3d physics. No clue how to go about reaching a similar result for the 2d physics.
    Can you help? @JeffersonHenrique
  • Hi @Wheathn, now I am a little busy with some other TrueSync stuff, but you can try to use the rotation we provide in TSTransform2D.
  • No problem. I got a friend of mine to come up with a facetowards/moveright solution using TSMath.trig.