How to make a rotating plane rotate (move) an object sitting on it - unity3d

I'm trying to make a car (or any object) in rotate when sitting on a plane surface or inside a tube shape. Currently the car acts like it has 0 grip on those surfaces (even tough the car moves without any problems when accelerating, but the objects don't move the car)
What I've tried so far:
putting a Physics Material on the tube & plane but has no effect
tuning the parameters of the Physics Material, no effect
marking the animation's Update Mode of the tube and plane as "Animate Physics", no effect
increasing the traction of the car (uses RCC), no effect
increasing the mass of the car..nothing
increasing mass of wheels, nothing
tried googling the problem, either didn't write the right terms or just couldn't find anything
Any help would be appreciated.
Thanks!

You need to rotate the plane and the tube using their Rigidbody with the AddTorque method or similar. If you just rotate them via their transform it has no effect on the physics system.

Related

It is impossible to implement accurate collisions in 3D SpriteRenderers? Is Billboard incompatible with rigidbodies?

I've been having difficulty implementing enemies with a billboarding system for a while:
For a new project I'm reusing some animated sprites from an old static camera shooter game I made. It consisted of shooting projectiles and hitting enemies advancing towards your position. The enemies were capsules which had an animated plane in front of them.
I wanted to go a step further and make a raycast system that would detect if the impact on a plane is on the alpha part of its texture. I achieved it using a SpriteRenderer and a plane that matched the size of the sprite which receives the impact of the Raycast.
The problem comes with the movement of the enemies. If I use Rigidbodies this conflicts with the plane which detects the impact, since I have to use a non-convex Mesh Collider for RaycastHit.textureCoord (With Convex colliders it doesn't return the correct position). I need Rigidbody based movement for the enemies to push each other when colliding.
I tried using Transform Movement, since the error does not occur, but this allows enemies to pass through each other and occupy the same space.
I started investigating navMesh but I'm not sure if it is possible to avoid collisions.
I started to place a group of trigger colliders on the enemy mimicking the shape of the sprite. But this makes it difficult for me to detect collisions when enemies do certain animations (Some enemies jump diagonally or their animations are a bit jittery).
I would like to keep the impact detection system for the sprite, but maybe there is another way to check the texture at the impact location.
I think my options are:
With rigidbody based movement: separate the animation and hit detection system from the enemy movement. And make the billboarding effect teleport to the object constantly.
With Transform movement: Detect if they are overlapping and move them in opposite direction to the overlapping to simulate the collision.
With motion based navMesh: I'm not sure if it will be useful to me, since the characters jump and I also believe that a Mesh Agent ship cannot simultaneously be an obstacle. I understand that the navMesh cannot be generated in runtime.
Leaving texture based detection and using the trigger colliders group: Animate the colliders to also follow the animations. Or simplify everything to a large collider, losing precision on impact.
-Find an alternative method to detect the impact coordinates in the texture, avoiding using RaycastHit.textureCoord and therefore Mesh Collider. (Although I would like to keep the impact detection system as it is, maybe there is a similar approach for the same result).
The reason I have not yet delved into these solutions is because I would like to keep the system simple. I'm trying to avoid separating the enemy into 2 gameobjects, simulating collisions or animating collider positions. I honestly don't know which way to go in order to move forward with the project.

Very weird position "snapping" with simple box colliders?

Im not even sure what is happening here but I'm just trying to make objects fall normally onto the floor - they need gravity/be able to be pushed around, but just fall onto a static floor object.
I have a cube and my floor mesh. Floor mesh has this:
Cube has this:
Initially I'll have my cube just positioned right over the floor. Then I press play and pause, within one second it's 100 m away, spinning/falling. What could be happening here?
You may face problems with small size colliders due to how the physics engine works. Increase size of colliders and see if it helps. If you really need colliders this small, try changing the Default Contact Offset in Physics Manager.

How to implement trolley-like physics behaviour in Unity

I am stuck with two things while trying to simulate the physics setup for a trolley-like object (push powered vehicle with free rotating wheels on the front and fixed wheels on the back).
I have the RigidBody with its mesh and four WheelColliders, the object moves fine if I just apply torque to the wheels. However if I use the AddForce method on the RigidBody it won't move; I see the object being pushed (slightly balancing) but the wheels won't rotate so it stays in place. How can I get the wheels to move if the object is being pushed?
My other problem is to simulate the standard 360 degrees rotating wheels on the front of the trolley. What would be the best way to simulate this? I was thinking about a horizontal WheelCollider and a vertical one as a child but that seems really weird and I doubt it will actually work. Any ideas?
https://docs.unity3d.com/Manual/WheelColliderTutorial.html
This tutorial shows an example of how to use the wheel colliders and apply steering and torque to them.
It might be what you are looking for in regards to the adding force part.
I suspect it might allow the 360 degree rotation as well, but I am not familiar enough with these colliders to guarantee that.
EDIT:
In the guide there is the line:
public float maxSteeringAngle; // maximum steer angle the wheel can have
Which looks relevant for the 360 degree turning.

Zooming In/Out of a OpenGL ES 2D Game Scene

What's the best method for pulling back to show more of a view in a 2D OpenGL iPhone game? For instance, in Tiny Wings, when the bird flies toward the top of the screen the bird and the scenery pull back to simulate the bird going higher in the sky. Would this effect be better achieved by scaling all the sprites proportionally, or by using glOrthof? In any case, I'm assuming that the zoom-out factor is inversely proportional to the player's y position.
You almost certainly want to use glOrthof so all you're changing is how the camera sees the scene. This avoids recomputing all the normals and such in the scene, saving quite a bit of work. It's also easier for you to implement.

Cocos2d - Creating collidable Sprites?

Hello everyone I an very new to cocos2d, so I apologize if this is a simple question. I would like to create to sprites that collide when they hit each other.
For instance, one sprite, spriteA, is in a fixed position on the screen. And another sprite, spriteB, is moving around the screen. SpriteB will collide with spriteA. If that doesn't make sense or you don't understand it, tell me and I will elaborate further. Any help is appreciated. Thank YOU!
Try using Chipmunk or Box2d physics systems. These are included with Cocos2d and work by having a physics simulation that updates with every time the graphics change on screen.
The physics simulation will tell you if two objects are overlapping, and will provide physical attributes like weight, slipperiness (friction), speed and direction, which creates reactions like bouncing, sliding, realistic loss of speed and changes of direction on impact.
If you are new to physics simulation, here's a 30 second run down:
Create "bodies" in the physics simulation that represent each graphical sprite
Bodies are usually defined more simply than their graphical counterparts, like a circle, square or simple polygon shape
In order to update the graphics on the screen accurately, first you establish a pixels to meters ratio. Meters are notional (i.e. made up) measurement that is used in the physics sim
Each time the physics simulation "ticks", you update the graphics on screen accordingly
So if a body in the physics sim moves 1 meter, you might transform the pixel sprite 32 pixels
Here's a good tute on collision detection using Box2d.
http://www.raywenderlich.com/606/how-to-use-box2d-for-just-collision-detection-with-cocos2d-iphone
enjoy
Its actually very simple:
Just schedule a timer: [self schedule:#selector(checkForCollision:)];
Specify the method: - (void)checkForCollision:(ccTime)dt {}
In the curly braces, make CGRects for each sprite using CGRectMake.
Then in the same method, just call: if (CGRectIntersectsRect) {}
That easy!
Well technically speaking when the 2 sprites interact, or share at least one common point, then they are colliding. I'm a little confused by your question. Are you asking for direction on how to make the sprite move on screen, or are you asking how to handle the actual collision(such as calling a method if they collide)?