Search Unity

Moving objects

Discussion in '2D' started by UDN_bf524d4e-2e97-40ca-829b-a6adec1daa76, Jul 25, 2016.

  1. UDN_bf524d4e-2e97-40ca-829b-a6adec1daa76

    UDN_bf524d4e-2e97-40ca-829b-a6adec1daa76

    Joined:
    Jul 23, 2016
    Posts:
    6
    I am trying to make a block move when it collides with another box collider. I want a cube to go on the oppisite direction on the Y axis when it collides. I followed a tutorial on how to do this with the X axis
    Code is here for X axis: http://pastebin.com/dxHBaWW7
    I have a linecaster while I was trying to get it to work
     
  2. LiterallyJeff

    LiterallyJeff

    Joined:
    Jan 21, 2015
    Posts:
    2,807
    Have you considered using the physics system for this? What do you mean "opposite direction on the Y axis". Do you mean the Y axis of the object, the object it collided with, or the global Y axis? Are all the objects moving? Or are they only moving vertically?