Add force to instantiated prefabs (c#)
Here is my code that I have right now but it doesn't seem to be working could anyone explain why? float x = player.transform.position.x; float y = player.transform.position.y; Vector2 origin = new...
View ArticleHow do i make jumps follow through with rigidbody2D.addforce?
i'm currently using the 2D character controller that comes in the Sample Assets package as a starting point for my 2D game. the thing is when you jump you can move around in the air, but when you stop...
View Article(2D) Need Object Moving with AddForce to Change Direction
So I need a player object that is under the effects of AddForce to move from one waypoint to the next to make a sharp directional change with no loss of momentum. Is there a way to do this? Right now I...
View ArticleHow can I make an object jump at the same height by applying the same force?
I'm working on a 2D game, when the user hits the jump button, the following c# script executes: void Jump(){ if(Jumping) return; if(Time.realtimeSinceStartup-LastJump>0.4f){...
View ArticleProblem with AddForce and direction
So..... I have a character that fires a ball; when the ball is fired towards the floor I want the character to have force added in the opposite direction to that which the ball was fired. I have tried...
View ArticleAddForce for spaceship acceleration, but with max speed
Hi. So in a top down space shooter, with movement controls very similar to Asteroids (classic) I'm using the following code to move my ship forward when I press the up arrow, and to rotate with...
View ArticleCharacter jumps in wrong direction
I'm creating a basic game that involves the character moving left to right and jumping. I have this code. void FixedUpdate() { //get input from up/down keys float moveVert = Input.GetAxis("Vertical");...
View ArticleMistake in Function with Collision and AddForce
Hi people! I'm trying to make this function work and I've spotted an error I can't seem to understand. What this is supposed to do is to make the head of a rope ( which the player can instantiate) act...
View Articlerigidbody.AddForce not working when Animator is attached?
Hey guys, so I currently have for my script a simply upward jump script, as shown below. if (Input.GetKeyDown(KeyCode.Space)) { rigidbody.AddForce(Vector3.up * jumpPower, ForceMode.VelocityChange); }...
View ArticleHow to create a gravitational pull effect on object?
I am trying to make a black hole kind of obstacle in a 2D platformer I am working on. I will have to fine tune the forces and such. But there is a problem. The effect only seems to apply in the Y axis....
View ArticleRandom instantiate at same frame with each instantiate having unique random...
Hello! This question should be rather short (and sweet!). I have an enemy type in my game dropping a random set of coins Range(1,10). Problem is, they all go the same way for my...
View ArticleHow do I apply force using Navmesh paths?
Hi, I have enemy spheres that I want to roll towards the player using the path that is generated by the nav mesh. When I use the navmesh.SetDestination, the spheres just slide towards the player...
View ArticleCan't seem to use AddForce
Just trying to use AddForce to add an upwards force to an instantiated sphere. Must be something I'm leaving out or not coding properly. Here's my code. Note: touchLength is a variable which will have...
View ArticleGet Momentum from AddForce
I want to create a damage mechanism based upon the force applied from the bullets. I'm using raycasting to apply the force, that's not the problem, but I'm trying to have the damage scale based on the...
View ArticleProblems with rigidbody2D.AddForce
Hi! , Im trying to get jumps like the game "the impossible game": https://www.youtube.com/watch?v=vW8nXTzroos Well, I wrote the essential, some rigidbody2D.AddForce to make the jump etc, the PROBLEM is...
View ArticleI need to add a force to an object based on the local vector of the object...
I have the following script attached the the "projectile" I thought that the "direction" variable take the vector3 of the owner of the script but it did not. I am a novice and I appreciate any...
View ArticleClones AddForce individual
Hello! I spawn enemie's balls from spawn scrip and I want to move every ball to different direction, but when I'm using rigidbody2D.AddForce for clones, the are moving the same direction whith every...
View ArticleAddForce Relative to Rotation
While I know this question has been asked a lot, mine is different than most of the others. :( -------- Well I'm attempting to figure out AddForce, and I'm having the common "addforce relative to...
View Articlemake addforce ignore player controller?
Hello Everyone, I am currently working on a 3d FPS game that enables the player to enter and pilot a underwater submarine pod. The pod uses the addRelativeForce on it's rigidbody since it slowly...
View Articlerigidbody2D addforce on x-axis
Hi there, I am trying to wall jumping into my 2d platformer. I have managed to code it so that a certain command will run when next to wall while in the air but it does not apply the force x-axis...
View Article