Unity, the interaction of people and mobile platforms

Source: Internet
Author: User

For example, the characters jump to the reciprocating movement of the platform should follow the platform movement.

To achieve this effect there are two ideas, one is to use kinematics one is to use dynamics.

First, the kinematic idea:

1, create a box as a mobile platform, using Unity's built-in animation curves to adjust the animation of the left and right reciprocating motion.

2, add rigidbody for mobile platform and Tick is kinematic. Thus, the moving platform itself is no longer subject to kinetic action, but it can have a kinetic effect on other objects. (While the rigidbody is marked iskinematic, it'll not being affected by collisions, forces, or any other part of ph Ysx. This means, you'll have the-control the object by manipulating the Transform component directly. Kinematic rigidbodies would affect other objects, but they themselves would is not being affected by physics. Citation: http://docs.unity3d.com/Manual/class-Rigidbody.html)

3, add a script for the mobile platform to achieve the following logic: If the player is on the platform (the player's foot touch the platform and the player is in a non-hop state), the player. RIGIDBODY.VELOCITY.XZ and platform Velocity.xz consistent, otherwise make player.rigidbody.velocity.xz= (0,0). Note: (1) One might ask if you let the player. Rigidbody.velocity.xz= (0,0), how can the player move under keyboard control? Because the player in my demo is moved under keyboard control by setting the player directly. Rigidbody.position is implemented, so player.rigidbody.velocity.xz= (0,0) does not affect the character movement. (2) Why is the player. Rigidbody.velocity.xz= (0,0), not the player. Rigidbody.velocity.xzy= (0,0,0)? Because the motion in the y Direction in my demo (Free Fall) is not set directly by the player. RIGIDBODY.POSITION.Y implemented by: D.

4, this is almost done, the only problem is to find that the people jump on the platform after the game has become less smooth (slightly lag), and can be seen not caused by performance problems. Later I tried to set the Animator of the platform as follows: Animator->update mode changed from normal to animate Physics, and the lag does not occur (for reasons not yet detailed analysis, you may need to learn more about animate Physics option) to achieve the desired effect.

Second, kinetic thinking (not yet tried):

In the real world, people jump on the mobile platform with the movement of the jumping platform, is due to friction, so you can try to adjust the platform and character foot friction between the properties to achieve, to add modified friction properties, you need to change the collider in the material of the physic Material (Create method: Right mouse button in asserts window->create->physic material).

Unity, people interacting with mobile platforms

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.