• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By RoKabium Games
      While looking out for that pesky Terrator, our little alien is doing a bit of relaxed mining down on the new gas planet "Lelantos" this weekend.... 
      #gamedev #indiedev #madewithunity #screenshotsaturday
    • By vividgamer
      I have a native iOS game (objective c, XCode build) which I am considering to port to other platforms.
      Core gameplay is based on solely on geographical maps, and custom drawing over maps. It also has Core Data. This part is complete in development.
      What is not done yet is: monetization, gamification (leaderboards, challenges) and multiplayer functionality.
      As I think more about it, I am tempted to think if this is the right time to move to a cross platform tool such as Unity. But before dedicating time to port my 5 years side-project effort in Objective C, I really want to know if its worth it.
      - Does Unity support such plugins / assets that will fulfill all my above requirements?
      - Unity Personal seems to have only 20 concurrent users - is it too costly scaling if I decide for extending to web and android platforms?
      - What is the general workflow involved in publishing to iOS, Android, PC, and web platforms while using Unity? I mean to ask about various points of signing stuff, paying fees and getting certified.
      - How long will it really take to port my entire Objective C project into Unity? I am somewhat familiar with C# but I am finding it hard fidgeting with Unity IDE as lot of things are focused around FPS and 3D while my game is still 2d - not much action involved. I seem bit overwhelmed by the list of features I see there. All in all, I do not want to lose my momentum while still making sure its portable to everywhere.
      - Any assets I could use (for free to try basis in debug) that are relevant for my game?
      - Last but not the least, are there any costs that I need to be paying upfront to Unity, for using it (apart from their monthly subscription model)? I don't understand their costing for multiplayer in conjunction with their subscription fees - if someone could kindly elaborate.
      Thanks in advance for your time reading a newbie
    • By GytisDev
      me and few friends are developing simple city building game with unity for a school project, think something like Banished but much simpler. I was tasked to create the path-finding for the game so I mostly followed this tutorial series up to episode 5. Then we created simple working system for cutting trees. The problem is that the path-finding is working like 90% of the time, then it get stuck randomly then there's clearly a way to the objective (tree). I tried looking for some pattern when it happens but can't find anything. So basically I need any tips for how I should approach this problem.
      Use this image to visualize the problem.
    • By aymen
      please any know how can i' calculate the centroid from any number vertices
    • By Henry Fernandez
      Good day sir/maam. I am developing a game for my thesis and im done with multiplayer and plan to start the implementation of AI but i dont know how/where to start. Please give an advice. I am developing it in C# using UNITY. 
      Im am now collected all pieces that has possible moves but i am stuck on which best move to select. I hope you will help me. This is link explained the game https://en.wikipedia.org/wiki/Game_of_the_Generals 

  • Advertisement
  • Advertisement
Sign in to follow this  

Unity Applying force to an object. (Unity)

This topic is 1252 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi every body. I have a problem about applying force to an object. My scene is this. There is two cube on the scene and they have distance 

between them. At the middele o f these 2 cuve there is a sphere. When the game start as soon as sphere hit the plane the plane applying just 

for 1 time a force to right. Then sphere hits the right cube and the cube applyes force to left, left cube applyes force to right, it goes in 

this way.

When player push the uparrow, I tried the eliminate all the forces on sphere and try to give force on forward direction. This codes are 

working good but sometimes when player shoots the ball it doesnt eliminates all power, sphere goes to forward and right or forward and left. 

What is the reason do you think.



Here is the video link maybe it helps to you for easier understanding. First shoot is okey for me but second one is fail. By the way for both shoots it says "SHOOT" at the console so it proves my codes in the uparrow case was worked.



" title="External link">



Here is the code.

public var first: int =1;
public var firstshoot: int =1;
function Start () {


function Update () {
if(Input.GetKeyDown(KeyCode.UpArrow)) {
rigidbody.velocity = Vector3.zero;
rigidbody.angularVelocity = Vector3.zero; 

rigidbody.AddForce(Vector3.forward * 3000);
Debug.Log ("Shoot");


function OnCollisionEnter (thecollision : Collision){

if (thecollision.gameObject.name == "FinishLine"){
Application.LoadLevel (0);

if (thecollision.gameObject.name == "Plane" && first == 1){
Debug.Log ("Floor Hit");
rigidbody.AddForce(Vector3.right * 500);

if (thecollision.gameObject.name == "Cube1" && firstshoot == 1){
Debug.Log ("Right Wall Hit");
rigidbody.AddForce(Vector3.right * -3000);

if (thecollision.gameObject.name == "Cube2" && firstshoot == 1){
Debug.Log ("Left Wall Hit");
rigidbody.AddForce(Vector3.right * 3000);


Edited by mamanybono

Share this post

Link to post
Share on other sites

I am suspecting about this, do you think, is it possible?

When my problem occurs, unity consol shows "Wright wall hit" then "Shoot" in this case, first wall applies force to ball on left direction, then uparrowe codes eliminate all forces and gives a forward force. But ball is moving to left side.

I think unity first reading codes for collision of right cube and shows the "Right wall hit", then it applies the force to left direction.

If ? push the uparrow button, while collision of right cube is occuring, system gives priority to my uparrow button and it is freezing the collision of right cube just after console writes "Right wall hit", then uparrow codes works, they eliminate all forces and gives just forward direction force, after uparrow codes finish, right cube collision continue and it applies to force on left direction.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement