Reputation:
I'm having trouble finding some pretty simple things with the new 2D Unity functions!
Firstly, am I right in thinking that rigidBody2D
doesn't have a position
variable like it's three-dimensional bigger brother? It was my understanding I should be using the rigidBody
positions, not transform.position
as this is in FixedUpdate
- so what am I supposed to do?
Secondly, I can't access the CircleCollider2D.radius
variable despite being listed in the documentation, and above this I can't even access gameOject.circleCollider2D
or gameObject.collider2D.circleCollider2D
in code (C#).
Am I going mad, Am I missing something, or is Unity missing something? =/
Cheers for any help anyone can give on this, even if it's to confirm something.
Upvotes: 0
Views: 823
Reputation: 278
if your game object has CircleCollider2d then, you will get circlecollider2d as follow.
1> Declare a variable for CircleCollider2d.
CircleCollider2d c_collider2d;
c_collider2d = gameObject.GetComponent<CircleCollider2d>();
c_collider2d.radius = 1.5f;//set radius value for collider.
RigidBody don't have position values, it always follow the game object where it is attached.
Upvotes: 2