Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: coffeeANDsoda on June 23, 2014, 09:08:38 PM

Title: decreasing speed of player without 2d wheels
Post by: coffeeANDsoda on June 23, 2014, 09:08:38 PM
I have a object that the player controls where it doesn't rely on a two wheel driving system. And in my game I want to set a object to trigger slowing down the players car.

How can I slow down the cars speed.
Title: Re: decreasing speed of player without 2d wheels
Post by: Alex Chouls on June 23, 2014, 11:59:59 PM
How about Add Force in the opposite direction?
Title: Re: decreasing speed of player without 2d wheels
Post by: coffeeANDsoda on June 24, 2014, 01:42:20 AM
How about Add Force in the opposite direction?

How would that work though? Because when I added that in a state, even with the other being connected with a trigger event, it falls off of the level.
Title: Re: decreasing speed of player without 2d wheels
Post by: sebaslive on June 25, 2014, 06:20:28 PM
How about a button that increases the drag on the rigid body and resets it when you let go?
Title: Re: decreasing speed of player without 2d wheels
Post by: coffeeANDsoda on June 25, 2014, 10:26:25 PM
How about a button that increases the drag on the rigid body and resets it when you let go?

What would that mean in terms of setting up the correct action for that state? Cause I'm trying to simulate mud.
Title: Re: decreasing speed of player without 2d wheels
Post by: Alex Chouls on June 26, 2014, 01:13:39 AM
You should be able to make a Physics Material to simulate mud, apply that to the surface and let the physics simulation handle the slowdown:
http://docs.unity3d.com/Manual/class-PhysicMaterial.html

No actions needed, just physics tweaking...

Unless you have to cheat and manipulate the drag (or other physics properties) as sebaslive suggests. There is a Set Drag action you could use, and a Set Property action to set other Rigidbody properties (there are videos on our YouTube channel showing how to use Get/Set Property).
Title: Re: decreasing speed of player without 2d wheels
Post by: coffeeANDsoda on June 29, 2014, 09:12:12 PM
When I add a rigidbody to the player with the standard movement scripts I get a error message.

Code: [Select]
Actor::updateMassFromShapes: Compute mesh inertia tensor failed for one of the actor's mesh shapes!Please Change mesh geometry or supply a tensor manually!

And for the player, I tried both quad and cube.
Title: Re: decreasing speed of player without 2d wheels
Post by: Alex Chouls on June 29, 2014, 09:18:57 PM
Are you using a Mesh Collider?

A quick search about this error:
http://answers.unity3d.com/questions/386168/updatemassfromshapes-error.html
Title: Re: decreasing speed of player without 2d wheels
Post by: coffeeANDsoda on June 29, 2014, 09:31:06 PM
Are you using a Mesh Collider?

Yes I am. I did remove it and got the same message. Do you think if has to do with actions simple move and controller settings?
Title: Re: decreasing speed of player without 2d wheels
Post by: Alex Chouls on June 29, 2014, 11:48:52 PM
Did you replace it with a primitive collider? I don't think it has anything to do with the actions since it happens with regular scripts too... I think it's more of a physics setup issue (with an unhelpful error message!).
Title: Re: decreasing speed of player without 2d wheels
Post by: coffeeANDsoda on June 30, 2014, 01:22:14 AM
Did you replace it with a primitive collider?

No. What would that be? A box collider?
Title: Re: decreasing speed of player without 2d wheels
Post by: Alex Chouls on June 30, 2014, 01:35:03 AM
Whichever primitive collider best matches the shape of the player (box, sphere, capsule)
Title: Re: decreasing speed of player without 2d wheels
Post by: coffeeANDsoda on June 30, 2014, 01:52:34 AM
Whichever primitive collider best matches the shape of the player (box, sphere, capsule)

Since it is the length of a car I used one and the this happens after the game pauses.

Code: [Select]
Actor::updateMassFromShapes: Compute mesh inertia tensor failed for one of the actor's mesh shapes! Please change mesh geometry or supply a tensor manually!
UnityEngine.CharacterController:SimpleMove(Vector3)
HutongGames.PlayMaker.Actions.ControllerSimpleMove:OnUpdate() (at Assets/PlayMaker/Actions/ControllerSimpleMove.cs:52)
HutongGames.PlayMaker.FsmState:OnUpdate()
HutongGames.PlayMaker.Fsm:UpdateState(FsmState)
HutongGames.PlayMaker.Fsm:Update()
PlayMakerFSM:Update()

and
Code: [Select]
Actor::updateMassFromShapes: Compute mesh inertia tensor failed for one of the actor's mesh shapes! Please change mesh geometry or supply a tensor manually!
UnityEngine.CharacterController:Move(Vector3)
CharacterMotor:UpdateFunction() (at Assets/Standard Assets/Character Controllers/Sources/Scripts/CharacterMotor.js:229)
CharacterMotor:FixedUpdate() (at Assets/Standard Assets/Character Controllers/Sources/Scripts/CharacterMotor.js:331)

What should I do when dealing with rigidbody settings? Cause you have collision detection settings, interpolate and everything else.
Title: Re: decreasing speed of player without 2d wheels
Post by: Alex Chouls on June 30, 2014, 02:24:02 AM
Do you have a mesh collider on one of the children?
Title: Re: decreasing speed of player without 2d wheels
Post by: coffeeANDsoda on June 30, 2014, 02:48:26 AM
Do you have a mesh collider on one of the children?

I have it set up so the drivers is inside of or part of the vehicle. I forgot to remove the mesh collider on the driver. So when I removed it and applied a box collider and rigidbody to the car the whole thing goes up in the air, settles, and then the camera freaks out.

Would I have to freeze the position in order to not make it do that?
Title: Re: decreasing speed of player without 2d wheels
Post by: Alex Chouls on June 30, 2014, 03:58:20 PM
Do you have any overlapping rigidbodies? If rigidbodies start in collision you can get some weird behaviour on startup while they push themselves apart...
Title: Re: decreasing speed of player without 2d wheels
Post by: coffeeANDsoda on July 01, 2014, 01:54:17 AM
Overlapping rigidbodies as in each of them have the same dragging attributes?