- Home /
No changing Linear Drag (.linearDrag) on rigidbody / rigidbody2D in code?
Hello I have detailed my issue here: http://tinyurl.com/p4kl2oz
It includes a video and my code.
Generally I note that you cannot change Linear Drag via code, unless someone can prove that wrong. If i'm right, why not? No .linearDrag ?. Also why does manually changing Linear Drag override your animations?
As you can see in the link above I am trying to create a boost platform for a 2D character using a rigidbody2D. Thanks for any help in advance.
code below: (requested)
int bounceAmount = 1;
IEnumerator Bounce () {
anim.SetBool ("Ground", false); // starts jump animation
//rigidbody2D.angularDrag = 10; //not helping, but is valid
//rigidbody2D.linearDrag = 10; //INVALID CODE, but manually works(helps)
(note: when Linear Drag is manually set to 10,the player drops back down but overrides the animation)
rigidbody2D.AddForce(new Vector2(0, bounceAmount ));
yield return new WaitForSeconds(1);
rigidbody2D.AddForce(new Vector2(0, -bounceAmount ));
bounce = false;
}
Please put the relevant code here ins$$anonymous$$d of a link.
@taylank add your comment as an asnwer, it is correct. it will help someone in the future.
Answer by taylank · May 31, 2014 at 09:47 PM
it's rigidbody.drag not .linearDrag Make sure to check the Unity scripting manual when you're stuck.
Your answer
![](https://koobas.hobune.stream/wayback/20220613150413im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How do i make piano key like physics? 1 Answer
,Spawning snow or changing tilesets to snow as the player walks past them 0 Answers
The name `PlatformerCharacter2D' does not exist in the current context 1 Answer
How to reset the Gravity of an object from script 1 Answer
Souls pickup mechanic (Like Dark Souls, BloodBourne) 0 Answers