Search Unity

[Released] Smart 2D Colliders ( including Smart Platform Controller )

Discussion in 'Assets and Asset Store' started by CreativeSpore, Oct 15, 2015.

  1. RedVonix

    RedVonix

    Joined:
    Dec 13, 2011
    Posts:
    422
    Do your colliders allow for collision point detection and return? So for example - say I have two rigid body colliders, and they touch each other. In the code, can I get a return value of the exact point where they are touching - and then continue to get that updated position for as long as they are continuing to touch?
     
  2. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    No, the smart colliders are only checking collisions against Unity colliders 2D and/or 3D. But not between them.
    So, to achieve than, you should add a collider 2D or 3D and set it as trigger.
    In that case, "void OnSmartTriggerStay2D(SmartContactPoint smartContactPoint)" will be invoked for all colliders found in the movement.
     
    Last edited: Jan 14, 2016
  3. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Hi there,

    I don't have Corgi engine so I didn't try, but it could be possible to use them together making some modifications.
    Based in my experience with the old version of 2D Platform Controller, the old version, not the new one, there is some things like checking if it's on ground, or allowing jumping down from pass thorough platforms you should manage well changing the original code, or adapting the smart rect collider so it is not affecting each other.

    But I don't think it would be really difficult to adapt. I've seen in a tutorial video Corgi use a rect as well so you could place the smart 2D collider in the middle.

    Maybe in the future I could buy Corgi and try to enhance it, but right now it won't be possible. Anyway if you try both, I could help you to connect both to work together.
     
    zwickarr likes this.
  4. DiscoFever

    DiscoFever

    Joined:
    Nov 16, 2014
    Posts:
    286
    Hi, considering the purchase. Question : Can I use this as an enemy ? Meaning do you you expose the controlling values so i can put some AI in it ? thanks
     
  5. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Yes, you can use the SmartRectCollider2D in an enemy.
    I use it for snails, for example, in scene 05 - Demo Mario.
    The logic for the player control is separated in another component called SmartPlatformController.
     
  6. DiscoFever

    DiscoFever

    Joined:
    Nov 16, 2014
    Posts:
    286
    Thanks, i just purchased the kit. But ...

    I have a gravity of -100 in my game; trying your player with this settings is just impossible and i cannot change gravity in all my game; this is a bad thing ... please add 'customGravity' setting ... i'm trying to figure out a 'smooth' movement with those settings. Glad if you can help me out here.
     
  7. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Are you using 3D or 2D physics?
     
  8. DiscoFever

    DiscoFever

    Joined:
    Nov 16, 2014
    Posts:
    286
    2D Physics
     
  9. DiscoFever

    DiscoFever

    Joined:
    Nov 16, 2014
    Posts:
    286
    In fact; it is falling "too fast"; like we can tune the jump but not the fall. Anything you can do here ?
     
  10. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Go to the rigidBody2D of the character and set the gravity scale to 0.18 (instead of 1.8, because your gravity is 10 times higher than default 9.8)
    EDIT: if you mean the enemies the value would be 0.1. Just divide by 10 the value in gravity scale.
     
    theANMATOR2b likes this.
  11. DiscoFever

    DiscoFever

    Joined:
    Nov 16, 2014
    Posts:
    286
    Ok seems to work; thanks !
     
  12. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    You are welcome ;)
     
  13. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Soon the next version of Smart Platform Colliders v1.1.0 will be available and it will come with a new and improved Platform Character Controller.

    This controller will allow you to create and customize your platform controller easily using handles and a couple of parameters.



    Check how easy it is to create and configure a platform controller in this video.
    There will be a prefab included and ready to work with the next version.

     

    Attached Files:

    Last edited: Apr 13, 2016
    theANMATOR2b likes this.
  14. KWaldt

    KWaldt

    Joined:
    Nov 1, 2013
    Posts:
    127
    Just bought this asset today--I'm looking forward to work with it, it really looks nice!

    Just as a question--you didn't implement a double jump mechanic, right?
    (I know there's this "holding the button thing", but I'm still not too sure about it.)
    It's not that hard to script it myself, but if it's already in the package, I'd rather use this since it makes updating the package easier.

    Best Regards,
    Kristina Waldt
     
    Last edited: Apr 24, 2016
  15. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Hi Kristina,

    Thanks for buying this asset ;)

    I will improve the asset in the next update and probably I will add some stuff like doble jumping, wall jumping, etc.
    I am thinking how to make it modular so it is easy and clean to add these abilities.
    Check this thread or follow me on twitter @CreativeSpore to be inform of future updates and working progress.

    Best regards,
    Juan
     
    KWaldt likes this.
  16. SVC-Games

    SVC-Games

    Joined:
    May 21, 2013
    Posts:
    137
    Hi there. I'm creating a platformer and I'm interested in the feature about stopping colliders no matter their speed. I won't be using your Smart Platform Controller (I have my own already, not for lack of faith in yours) but I'd like to know if your colliders replace unity standard colliders. Sometimes my high-speed bullets seem to move beyond walls, even with raycasting.

    Thanks in advance
     
  17. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Yes, I replace unity standard collider Box 2D to create a box 2D collider with some enhanced features and also working with 2D and 3D colliders at the same time.
    They are not trespassing colliders no matter the speed as you can see in Demo Pinball:
    https://creativespore.itch.io/smart2dcolliders


    Maybe what you are doing wrong is creating them inside a wall when you are too close?
     
    Last edited: Apr 25, 2016
  18. SVC-Games

    SVC-Games

    Joined:
    May 21, 2013
    Posts:
    137
    Oh, I haven't tried yours yet, I just wanted to know if I can use your colliders with my platform controller (right now it uses standard colliders and raycasting). Seems like your colliders might solve my problem. I just wanted to make sure that it works even without using your platform controller
     
  19. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    How do you check the collisions with raycast? For a bullet you could simple make a raycast from previous transform.position to current position. That should work.
    Code (CSharp):
    1. Vector3 m_prevPos;
    2. void Start()
    3. {
    4.     m_prevPos = transform.position;
    5. }
    6.  
    7. void FixedUpdate()
    8. {
    9.     Ray ray = new Ray(m_prevPos, transform.position - m_prevPos);
    10.     m_prevPos = transform.position;
    11.     if(Physics.Raycast(ray))
    12.     {
    13.         Destroy(gameObject)//Destroy Bullet
    14.     }
    15. }
     
  20. SVC-Games

    SVC-Games

    Joined:
    May 21, 2013
    Posts:
    137
    I do that but I have problems if the bullet goes at high speed and the target collider is moving towards the bullet.
     
  21. KWaldt

    KWaldt

    Joined:
    Nov 1, 2013
    Posts:
    127
    The plans for the character controller sound great!

    I have another question--is it possible to still let the player be pushed around by moving colliders?
    Even if I activate the rigidbody, the SmartPlatformCollider doesn't seem to react.
    I have some moving things that need to affect the player by pushing him, but I have trouble with this using your collider.

    Best Regards,
    Kristina
     
  22. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Change this:
    m_prevPos = transform.position;
    for this:
    if(Time.frameCount % 2 == 0)
    {
    m_prevPos = transform.position;
    }
    if you still have problems, change 2 for 3, 4, etc. But I think 2 or 3 would be ok.
     
  23. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Yes, it is possible.
    You need to increase the skin to detect the other moving objects in case they are moving too fast and be sure the other object layer is included in the "Layer Collision" mask property of the SmartRectCollider2D or SmartPlatformCollider2D component.
    Also, increase the value of SkinRightOff01 and SkinLeftOff01: In the Start method, add this:
    Code (CSharp):
    1.  
    2. m_smartRectCollider.SkinRightOff01 = 0.1f;
    3. m_smartRectCollider.SkinLeftOff01 = 0.1f;
    4.  
    or this is you are using the PlatformCharacterController:
    Code (CSharp):
    1.  
    2. m_smartCollider.SkinRightOff01 = 0.1f;
    3. m_smartCollider.SkinLeftOff01 = 0.1f;
    4.  
    Increase the value, between 0..1 until you don't have problems to be pushed by other objects.
     
  24. KWaldt

    KWaldt

    Joined:
    Nov 1, 2013
    Posts:
    127
    Hi!

    Thanks for the code--I set it to 1, and increased the skin, and it's working better now.
    However, if the movement is "too fast", it still glitches through sometimes (I tried to decrease the timestep in Unity, but it also didn't solve it completly). Do you think that this can be solved, or is this just a Unity-thing?
     
    Last edited: Apr 28, 2016
  25. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Can you send me a demo of explain me the problem with a screenshot?
    Maybe I can find a better solution.
     
  26. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    I have 2-3 issues:

    How would I (specifically) handle this system if I wanted to disable the provided jump and state systems completely and use my own? For example, I would prefer to use the physics system solely to resolve collisions, but I want to handle the jump and fall motions, particularly when it comes to the vertical motion myself (while still knowing if we're on the ground, etc.) and I want to get updated when the physics system says we're in a particular state (jump/fall/onplatform) so that I can drive the up/down physics and the animation of my character using my own methods (or state machine). Essentially the platform controller would be a dumb (smart) physics handler -- leaving input and everything else regarding the player state and motion to me (aside from the "are you in a wall/floor?" sort of stuff. Can you please show me the code to make this happen?

    Additionally, what would it take to use a 3d character with this system instead of a 2d one?
     
  27. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Hi there,

    Yes, you can easily remove the controller and the smart collider because they are separated components.
    You have the SmartRectCollider2D component to manage the collisions with the world. It's like the Box2DCollider but it works better and have unique features. Also detect 2D & 3D colliders at the same time.
    If you check the first post or this link you can see all features performed by this smart colliders. Almost all gifs are related with the SmartRectCollider2D.

    What I do with the PlatformCharacterController is the logic to jump, fall down from floating platforms, moving right and left, and manage the player states. You can also use some features of PlatformCharacterController and build your controller over it. You will see it's really easy to understand and if you have troubles, I can give you a hand.
     
  28. dth

    dth

    Joined:
    Oct 16, 2013
    Posts:
    13
    Shouldn't the "Smart Rect Collider" take care of the collisions? Why I still need to put a "Box Collider" on my objects?
     
  29. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    I didn't say that. I said, the SmartRectCollider2D is like a Box2D. It is a 2D rect that takes care of the collisions against the world and other things too like attaching to moving platforms, etc
    You can use only the SmartRectCollider2D and there is no need of a box 2D collider unless you want to check something specific with it.
     
  30. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    @CreativeSpore
    Thank you very much for your help! I will be looking into how to utilize this in my own setup! Unfortunately the examples weren't clear enough to show me it could be used this way, so I was stumped -- especially after I found two examples where the player character appeared to use different versions of the engine via controller scripts! Once again, I definitely appreciate the clarification! So thanks again!

    Btw, how would this work with online physics timing? I noticed it overrides FixedUpdate, so I'm assuming it handles delta time properly for predictive physics as well?
     
  31. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    You are welcome ;)

    I have to clarify. When I created this asset it was supposed to be an enhanced rectangle collider to be used mainly but not necessarily for a platform controller.
    But I created a simple controller Smart Platform Controller to have an example of how using the smart rect collider in your own controller.
    But some users asked me for a better controller so they don't have to make their own and be able to customize it, so I decided to create also an user friendly and easy to configure controller: the Platform Character Controller

    All demos included but the last one are using the first controller. It is a better choose if you want a controller based on unity physics, because the smart rect collider is integrated with them. Also it is a 4x4 controller you can rotate, scale, change gravity of the level, walk over a bunch of colliders, etc and it will work.

    The new controller is more focused to create a platformer controller for non programmer users or users with less programming skills that just whant the player to jump this high, fall at this speed, etc
    I will keep improving the last controller in future updates.
    For this controller, there is only a demo scene, the 08 - Demo New Platform Controller

    About the online physics. I didn't try them, but it should work in both cases, the Smart Platform Controller and the Platform Character Controller.
    I only see a problem and it is the way Unity apply the drag value but I guess they took that into account.
    The drag has a timing dependency, but it is fixed by simply splitting the time in physic time increments.
    For example, if the normal deltaTime is 0.02, and using online you get 0.04, you can execute two times the physics update using 0.02.
    Code (CSharp):
    1.  
    2. float dt = m_dtRemainder;
    3. for(dt += Time.deltaTime; dt >= 0.02f; dt-=0.02f)
    4. {
    5.     m_platformPhysics.UpdatePhysics(0.02f);
    6. }
    7. m_dtRemainder = dt;
    8.  
    This is an example using the Platform Character Controller that has its own physics management m_platformPhysics.
    You need to keep the remainder only in case deltaTime is not multiple of 0.02.
    m_dtRemainder should be a member variable to keep the value until next fixed update call.
     
  32. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    Is there any way to modify the Platform Character Controller script to accept a simple movement speed input (such as setting an hspeed and vspeed directly, and additionally, movement in a particular direction with a particular speed?) I don't want to mess with acceleration/friction/drag/etc.and would prefer to avoid it at all costs unless I absolutely need it. (I'd also prefer slopes to handle this integer-like speed with acceleration/friction automatically still, if I want it enable to do so, otherwise I want the movement to go steady up slopes if I don't want acceleration handled that way.

    My biggest problem is how the jump arc handles upward+forward momentum by combining them all and limiting the fall speed based on horizontal movement speed -- I want gravity, and particularly, falling speed to always remain constant and I'd like my character to always fall at the speed he falls unless I tell him to do so otherwise. Mainly, I'd like to control the jump's vertical motion entirely, letting horizontal motion act on its own (using the current system), aside from the function I mentioned before where you can set direction and speed simultaneously. It would be cool to have a function where you can set movement based on a curve defined in the inspector that would take into account the current horz/vert speed settings set currently to let that define the arc (and have the option to allow gravity to take over at the end of the curve's duration) to allow the player to fall (as if he were hit by a big baddie or some other such hard thing and knocked away).

    Aside from setting independent movement speeds, could you point me to how to change the states manually? I'm not sure how this system currently works when used alongside physics system such as jumping/falling and one-way platforms / slopes.
     
    Last edited: May 10, 2016
  33. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Hi there,

    Yes you can change the code below "// Moving Action" for this:
    Code (csharp):
    1.  
    2. // Moving Action
    3. if (GetActionState(eControllerActions.Right))
    4. {
    5.     m_platformPhysics.HSpeed = HorizontalMovingAcc;
    6. }
    7. else if (GetActionState(eControllerActions.Left))
    8. {
    9.     m_platformPhysics.HSpeed = -HorizontalMovingAcc;
    10. }
    11. else
    12. {
    13.     m_platformPhysics.HSpeed = 0;
    14. }
    15.  
    If you want to keep the original code, you can modify the code below "//Update Position" in UpdatePhysics:
    Code (csharp):
    1.  
    2. // Update Position
    3. m_prevPos = m_pos;
    4. Vector3 disp = m_vel * timeDt + .5f * m_acc * timeDt * timeDt;
    5. disp.x = Mathf.Clamp(disp.x, -m_maxHSpeed * timeDt, m_maxHSpeed * timeDt);
    6. m_pos += disp;
    7.  
    This modification will be included in the next release. This allow you to change the MovingAcc to a high value, like 500 so the speed is set to the maximum speed (Max. Walking Speed) in one update (It's a trick because the acceleration is added to the velocity and then the velocity is clamped to the maximum value, so if you max speed is less than MovingAcc, the maximum speed will be reached immediately)
    Remember to do the same with Airborne Acc.
    You can also set the drag factor to 0, but then you have to set the HSpeed to 0 when you want to stop moving, or play with high values of Acc and Drag to move at maximum speed faster and stop faster when you are not accelerating.

    About your second question, the falling speed is not limited by horizontal speed. What the arc is shown is a real prediction of a jump while moving in one direction all the time. But the falling speed is clamped to the Terminal Velocity value. No matter what gravity value you have, the player won't fall faster than that, unless you set 0 to remove the limitation.

    About defining your own curve while jumping, it depends on many things like, do you want to have airborne movement while jumping? otherwise you would be taking about doing a jumping animation and it's not the purpose of this asset.
    The idea is using platform oriented physics for the movement and the other thing would be playing an animation locally to the player position each time it is jumping.

    About the states, you can set an state action using the method SetActionState(eControllerActions action, bool value).
    If you want to move the player right you can call this action:
    Code (csharp):
    1.  
    2. m_platformCtrl.SetActionState(eControllerActions.Right, true);
    3.  
    To stop moving right call this:
    Code (csharp):
    1.  
    2. m_platformCtrl.SetActionState(eControllerActions.Right, false);
    3.  
    You can see an example of this in the PlatformCharacterInput.cs:
    Code (csharp):
    1.  
    2. m_platformCtrl.SetActionState(eControllerActions.Left, Input.GetKey(KeyCode.LeftArrow));
    3. m_platformCtrl.SetActionState(eControllerActions.Right, Input.GetKey(KeyCode.RightArrow));
    4. m_platformCtrl.SetActionState(eControllerActions.Up, Input.GetKey(KeyCode.UpArrow));
    5. m_platformCtrl.SetActionState(eControllerActions.Down, Input.GetKey(KeyCode.DownArrow));
    6. m_platformCtrl.SetActionState(eControllerActions.PlatformDropDown, Input.GetButton("Jump") && Input.GetKey(KeyCode.DownArrow));
    7. m_platformCtrl.SetActionState(eControllerActions.Jump, Input.GetButton("Jump") && !Input.GetKey(KeyCode.DownArrow));          
    8.  
    If I forgot to explain you something or you need more help let me know.

     
  34. ZeldaS

    ZeldaS

    Joined:
    Jul 3, 2013
    Posts:
    3
    (My English skill is very low)
    I changed Time.detaltime -> Time.fixedDeltatime in SmartRectCollider2D PlatformCharacterController.
    more smooth moving feel like.
     
  35. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
  36. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    I have found a bug when detecting the ground with scaled gameobject. It's a small fix and it will be included in next release.
    In SmartPlatformCollider.cs change line 21:
    float dist = SkinBottomWidth * transform.localScale.y + SmartPlatformCollider.k_SkinMinWidth;
     
  37. Grafos

    Grafos

    Joined:
    Aug 30, 2011
    Posts:
    231
    Hi,
    Love the plugin, gave such a nice boost to my game in these initial stages. I do have one question though.
    How can I add actions/animations such as attacks and jump attacks. I tried to modify the relative scripts, but soon got very lost and very confused. Is there a kind of modular/semi-modelar way?
     
  38. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Hi there,
    I'm glad you like it ;)
    Adding a new animation state is easy.
    For the animation management you have to use the script PlatformCharacterAnimator.
    Add a new state in the eState enumerator like Attacking and JumpAttacking.
    The attack state is similar in functionality to the climbing state. Check how it is managed:
    Code (CSharp):
    1. if( m_platformCtrl.IsClimbing )
    2. {
    3.     m_nextState = m_platformCtrl.GetActionState(
    4.         eControllerActions.Left | eControllerActions.Right |
    5.         eControllerActions.Up | eControllerActions.Down) ? eState.Climbing : eState.ClimbingIdle;
    6. }
    7. else if(m_platformCtrl.IsGrounded)
    8. {
    9.     m_nextState = m_platformCtrl.GetActionState(eControllerActions.Left | eControllerActions.Right) ? eState.Walking : eState.Idle;
    10. }
    11. else
    12. {
    13.     m_nextState = m_platformCtrl.PlatformCharacterPhysics.VSpeed > 0f ? eState.Jumping: eState.Falling;
    14. }
    15.  
    You only need to add a IsAttacking property to the PlatformCharacterController so you can check this property:
    Code (CSharp):
    1.  
    2. if(m_platformCtrl.IsAttacking)
    3. {  
    4.     m_nextState = m_platformCtrl.IsGrounded ? eState.Attacking : eState.JumpAttacking;
    5. }
    6. else if( m_platformCtrl.IsClimbing )
    7. {
    8.     m_nextState = m_platformCtrl.GetActionState(
    9.         eControllerActions.Left | eControllerActions.Right |
    10.         eControllerActions.Up | eControllerActions.Down) ? eState.Climbing : eState.ClimbingIdle;
    11. }
    12. else if(m_platformCtrl.IsGrounded)
    13. {
    14.     m_nextState = m_platformCtrl.GetActionState(eControllerActions.Left | eControllerActions.Right) ? eState.Walking : eState.Idle;
    15. }
    16. else
    17. {
    18.     m_nextState = m_platformCtrl.PlatformCharacterPhysics.VSpeed > 0f ? eState.Jumping: eState.Falling;
    19. }
    20.  
    In the PlatformCharacterController add a new action state for attack in eControllerActions (Attack)
    So you can set this action through the PlatformCharacterInput:
    Code (CSharp):
    1. m_platformCtrl.HorizontalSpeedScale = m_platformCtrl.VerticalSpeedScale = 1f;
    2. m_platformCtrl.SetActionState(eControllerActions.Left, Input.GetKey(KeyCode.LeftArrow));
    3. m_platformCtrl.SetActionState(eControllerActions.Right, Input.GetKey(KeyCode.RightArrow));
    4. m_platformCtrl.SetActionState(eControllerActions.Up, Input.GetKey(KeyCode.UpArrow));
    5. m_platformCtrl.SetActionState(eControllerActions.Down, Input.GetKey(KeyCode.DownArrow));
    6. m_platformCtrl.SetActionState(eControllerActions.PlatformDropDown, Input.GetButton("Jump") && Input.GetKey(KeyCode.DownArrow));
    7. m_platformCtrl.SetActionState(eControllerActions.Jump, Input.GetButton("Jump") && !Input.GetKey(KeyCode.DownArrow));
    8. m_platformCtrl.SetActionState(eControllerActions.Jump, Input.GetButton("Attack"));
    Finally, set the IsAttacking property in the PlatformCharacterController FixedUpdate method using a timer so the attack state remains for a while:
    Code (CSharp):
    1. if( GetActionState(eControllerActions.Attack)  )
    2. {
    3.     m_attackTimer = 0.3f; //0.3 seconds
    4. }
    5. if(m_attackTimer > 0f) m_attackTimer-=Time.deltaTime;
    The property IsAttacking could be like this:
    Code (CSharp):
    1. public bool IsAttacking{ get{ return m_attackTimer <= 0f; }}
    And the last thing is, if you don't want the player to move while attaking, change the if(!m_isClimbing) for:
    if(!m_isClimbing && !IsAttacking) at the beginning of FixedUpdated method.
     
  39. Deleted User

    Deleted User

    Guest

    I bought both this product and your Super Tilemap Editor. However, I cannot get your one-way collisions to work with your Super Tilemap Editor.

    How can I get both of your products to work together?
     
    Last edited by a moderator: Jun 25, 2016
  40. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    You have to setup it properly.
    First, create a tilemap with collisions and set the layer of the tilemap gameobject to the layer you are using for one.way collisions, like PassThrough. In the popup asking to change the children select yes.
    To use one-way collisions, if you are using the PlatformCharacterController, set the pass through layer in the PassThrough layers in the Physic Parameters section.
    Alternatively, you can set the "One Way Collisions\Down" property in the SmartRectCollider2D component, or SmartPlatformCollider component.
     
  41. Deleted User

    Deleted User

    Guest

    Thank you for your reply. The problem is that your one way platforms expect edge Colliders. So when I drop down a platform, I go thru the top of it and then I stop at the bottom of it. So I have to drop down a platform twice to actually go through it. Any ideas to solve this? Is increasing the drop down time the correct way to fix this issue? Thanks!!
     
  42. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    I would use edge colliders instead of polygon colliders. Why are your using polygon colliders? is it needed for other scripts?
    It is always recommended using edge colliders. The drop down from a platform works by disabling the bottom colliders for a while. But the idea is, once the bottom skin pass through the edge collider, it is enabled again to be placed over the next collider found. In case of a polygon collider, it doesn't work, because you are colliding inside the collider.

    The only reason to use a polygon collider is for special areas like a ladder, a climbing area or water, were you need to check if you are inside all the time.
     
  43. Deleted User

    Deleted User

    Guest

    I forgot to mention that I am using your Super Tilemap Editor. (Which is great!) So I am applying an edge collider, but that edge collider goes around the entire platform. I am not sure which forum to ask this on :)

    I am not at my computer right now, but I'll edit this post with a screen shot later.
     
  44. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    For one-way platforms, it's better to use a thin collider. For example, if you are using a tile with a bridge, you should reduce the collider to fit the bridge, but even if the bridge width has the size of a tile, you should move the bottom vertices of the default box collider to reduce the width only to be in the top part.

    As I said, the dropping down from a platform works by disabling the bottom collider for a while, and re-enabling it later, so the collider should be a thin enough and avoid using full tile collider in these cases.

    Normally, there is a different tile for top areas, the one with grass on top, for example. What I don't know is if you are using the same tile for the whole wall. Anyway, send me an screenshot when you can and I will tell you more ;)
     
  45. Deleted User

    Deleted User

    Guest

    Shrinking the collider to the height of a pixel fixed it problem. Thanks! And I love your tools. Really speeds up my workflow!
     
  46. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Great! It's good to know you like my tools ;)
    Let me know if you need more help
     
  47. Adoll

    Adoll

    Joined:
    Apr 16, 2016
    Posts:
    20
    Hi, thanks for bringing this asset to life, but I have an issue with it:
    I need to creat a circular world similar to your galaxy demo. Before integrating smart collider, I used the transform.RotateAround to make oibjects move around. After imorting this asset and using smart rect collider, the collision handling works fine, but the objects moved in a really wierd jittery fashion. The way in your galaxy example is to rotate the object towarding the center in each update and then move to the local right some distance. This works with objects affected by gravity but not with cannonballs. The cannonballs would move away from the center of the plannet gradually since this is not an actual cicular motion. Can you update the asset a bit to solve the jittery problem or can you offer a solution to move objects in circular world with steady altidtude?
     
  48. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Hi there,
    I will have a look into it. The jittery movement could be caused for different things:
    • The PixelPerfectCamera has enabled the Pixel Perfect property. This makes the camera to snap it's position to the pixel size and it's not good in a circular level. I disabled it in the galaxy demo scene.
    • In the SmartRectCollider, check the Pixel Snap is not enabled. This will make the position to be snapped to the pixel and could lead to a jittery movement if not used properly.
    For the cannonballs, it's normal if there is some imprecision for each frame. The imprecision is small enough to not affect too much during the lifetime of the rocket, normally less than a cycle around the planet.
    But I have modified the script anyways to unlock the distance to the target it moves towards to.
    You will find the modified scripts attached to this message.
     

    Attached Files:

  49. Adoll

    Adoll

    Joined:
    Apr 16, 2016
    Posts:
    20

    Thanks for the reply.
    The reason I need to use transform.rotatearound is that my player object needs that since it might not be affected by gravity in certain situations. So adding a timer to destroy is not the solution.
    Neither enabling nor not enabling Pixel Snap helped either.
    I realize I did not describe the problem clearly enough since "wierd jittery fashion" is far too vague. The weird part is that the object itself actually moved smoothly. In the scene view, the piviot and the collider moved well, but the graphic rendered were jittering, and this only happened when both transform.rotatearound and smart collider were used. So the camera setting does not matter in the current situation, the camera moved smoothly as well.
     
  50. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    I see. The problem could be in the execution order of the scripts.
    All movements to the gameObjects with SmartRectColliders should be done in the FixedUpdate and the script be executed before the SmartRect2DCollider2D script. This is the only way to be sure the SmartRectCollider2D is solving the collisions properly after object is in the final position.

    What I found was, the unity physics sometimes change the position before the call to FixedUpdate and sometimes after the call (like gravity) I don't know why. So what I did was save the position fixed by the smart collider in the FixedUpdate and when it is going to be renderer, I use that position. Otherwise if gravity was big enough, you would see the player with a down displacement. The problem with this is, if you change the position, the change won't be affected until the next fixed update.

    If you have still problems after calling transform.rotatearound inside a FixedUpdate and after moving the execution order of the script above the SmartRectCollider2D, send me a test project, if possible, so I can check it myself.