Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question, Prevent different objects sizes from colliding only in the middle

Discussion in 'Scripting' started by ninjakka, Aug 9, 2016.

  1. ninjakka

    ninjakka

    Joined:
    Aug 9, 2016
    Posts:
    4
    .
     
    Last edited: Aug 16, 2016
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,370
  3. LiterallyJeff

    LiterallyJeff

    Joined:
    Jan 21, 2015
    Posts:
    2,802
    Can you explain what is going on in your screenshots? What is happening, and what do you want to happen?
     
    Kurt-Dekker likes this.
  4. ninjakka

    ninjakka

    Joined:
    Aug 9, 2016
    Posts:
    4
    Hi, i updated my Post.
     
  5. LiterallyJeff

    LiterallyJeff

    Joined:
    Jan 21, 2015
    Posts:
    2,802
    Instead of a raycast downward, which is only the dimensions of a line, try using one or more BoxCasts. You can cast the dimensions of your entire block downward and check for collisions that way, or if your block is made up of many blocks, you can have each block cast its respective shape downwards to check for collisions.


    Alternatively you can do more raycasts, one at each corner and in the center. If this is a grid based world (which it appears to be), then this should be reliable.

    https://docs.unity3d.com/ScriptReference/Physics.BoxCast.html
     
    ninjakka likes this.
  6. ninjakka

    ninjakka

    Joined:
    Aug 9, 2016
    Posts:
    4
    I cant find any support on Unity 4.7.2 for BoxCast. Or am I missing something? I cant upgrade to Unity 5, i have to work with that older Version.

    I tried it with SphereCast but could not get it to work..
     
  7. jimroberts

    jimroberts

    Joined:
    Sep 4, 2014
    Posts:
    560
    Is there a reason why you can't use trigger colliders for this?

    P.S. Why can't you upgrade Unity?
     
  8. ninjakka

    ninjakka

    Joined:
    Aug 9, 2016
    Posts:
    4
    Hi, I am doing my Bachelor Thesis and have to use the last Unity 4 Version. (Whole project is done with that version). When I enable a collider, the object starts hopping and jumping around when i move it.
     
  9. jimroberts

    jimroberts

    Joined:
    Sep 4, 2014
    Posts:
    560
    Did you check the "Is Trigger" box on the collider?