RigidBody2d AddForce not working
I am new to unity and just trying to move a ball (prefab) up. I want to create the ball using the script, which works, I see the ball on the screen so it instantiates correctly. But when I try to ally force to the ball nothing happens. Currently the setting variables are set to: Gravity: 0, Simulated: true, Body Type: Dynamic, Mass: 1, Angular Drag: 1
here is my script:
I am not sure what I am doing wrong, any help would be appreciated, thanks.
Answer by Nightm4reProds · Oct 18, 2017 at 02:57 PM
If your game is 2D you cant use Vector3 (I think). Change it and tell me if it worked. @Priviera
I changed it to: ball.transform.position = new Vector2(0f,0f); and it still did not work, although it still Instantiates correctly, the ball does not move
Have you tried creating it by your own, without the script? I still dont know what you're really trying. Do you want to just move a ball? Do you want to create it and allowe it to move from a script?
All I am trying to do is move a ball up, I am just playing with forces, and I tried using ball = GetComponent(); ball.AddForce(Vector2.up * 1000f);
but that failed also, is there something else i need to do to the object before i can move it?
Your answer
Follow this Question
Related Questions
RigidBody only moves when I remove Collider 2 Answers
Why doesn't my knockback function apply force to it's target? 1 Answer
RigidBody2D.AddForce() horizontally is not working! 2 Answers
How to make arrows fly to user mouse position? 0 Answers
Rigidbody Addforce not working as expected ( video included) 0 Answers