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. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Different views for physics working

Discussion in 'Physics' started by glad, May 23, 2018.

  1. glad

    glad

    Joined:
    May 10, 2014
    Posts:
    76
    Hello.

    I'll try to be short. There is 2D physics. There is a ground(big plane or number of boxes - doesn't matter). On the ground there is a springboard. There is a car.
    So there could be 2 situations: either we could move the car towards the springboard or we could move groud towards the car. Mr.Enstein would probably say that there is no difference. And I would say the same. However in Unity there is difference. In the case when ground is moving towards the car the car is not gathering the desired altitude when jumping after springboard. I wonder why it is so ?

    Thanks in advance.
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,470
    For starters, this isn't real life, it's an approximation/simulation of such. ;)

    In real terms, is your ground static? If so then are you just re-positioning it to simulate movement? If so that doesn't exist in the real world either i.e. teleporting from one point in space to another and no velocity is realy involve therefore no energy is transfer via friction or through any other method.

    Of course I'm guessing on your set-up and I could be way off from what you've got setup. Maybe you could ellaborate on the body-types involved and how each moves in the situations you describe then maybe I can help figure out how to best get what you want working.
     
  3. glad

    glad

    Joined:
    May 10, 2014
    Posts:
    76
    I am writing an infinite runner in 3D. Since the car is moving only forward I use 2D physics. The ground is static, but the springboard is not. Ground is a large box(collider) that not moving. The car is also not moving. Only the springboard is moving towards the player(car).

    The structure is following: there is levelgenerator object at the top of hierarchy, and it has children(springboards) that are colliders. So I move levelgenerator object by physics in a following way:

    Code (CSharp):
    1. m_rigidbody.MovePosition(transform.position - dir);
    1.png
     
  4. FMark92

    FMark92

    Joined:
    May 18, 2017
    Posts:
    1,244
    Move the car using physics (force and velocity) and move everything so that car is in screen center in LateUpdate. (transform.position = ...)

    Best of both worlds.
     
  5. glad

    glad

    Joined:
    May 10, 2014
    Posts:
    76
    Tried now to move the world using velocity. It moved several seconds and suddenly stopped. The velocity is changed to zero vector and there is no way to turn it back. I suspect something is preventing it to move further. Investigating.
     
  6. glad

    glad

    Joined:
    May 10, 2014
    Posts:
    76
    Indeed there were obstacles that was preventing world to move. Fixed it. But still the car isn't gathring correct altitude: as long as the car leaves the springboard it loosing the altitude, but the car should have some inertia and increase altitude some time.