Search Unity

Screen space to WolrdSpace problem!!! (300$ PRIZE!!!!!!)

Discussion in 'Scripting' started by myunity, Apr 8, 2010.

  1. apple_motion

    apple_motion

    Joined:
    Jul 2, 2009
    Posts:
    169
    I guess the problem is your understanding of "view" system :roll:

    How about switch the camera to Orthographic mode 8) Everything become 2D !!!
    (Don't PM me, please :? )
     
  2. apple_motion

    apple_motion

    Joined:
    Jul 2, 2009
    Posts:
    169
    James Foley can help you !
     
  3. myunity

    myunity

    Joined:
    Nov 7, 2009
    Posts:
    117
    ok thanks for nice help!!!!
     
  4. FrimaMickD

    FrimaMickD

    Joined:
    Jan 4, 2010
    Posts:
    7
    Hi, maybe you have already resolved your problem but I tested your demo and the "problem" you seem to be having is not really one, its a normal perspective effect.

    The fact that you see the bullet go left or right is because this is how you perceive the bullet falling due to gravity when you shoot it in the left or right corner of the screen.

    Now what I would propose, and maybe that is not what you intend to do but this perspective problem would be solved, is that you always spawn the bullet with the direction the camera is looking at and not the position of the mouse in the screen. The mouse will still be used to "target" and you would always have the desired effect.

    If you are looking for a simulation I believe this would solve the problem. Check how its done in FPS games, your camera does not reflect the correct behavior I believe. If you want me to do a demo or something tell me, I might take some time to make this.

    Hope you solve your problem soon !

    Mick
     
  5. myunity

    myunity

    Joined:
    Nov 7, 2009
    Posts:
    117
    Hi Mick,

    If you can please solve this problem and make a demo.i pay offer for it.

    in addition,if mouse click position make problem you can make random x,y(pixel coordinate) and then instantiate the bullet in tht random x,y.

    thanks for your help.i am waiting for your more help.
     
  6. FrimaMickD

    FrimaMickD

    Joined:
    Jan 4, 2010
    Posts:
    7
    Like I said before, you do not really have a problem. There is no bug to correct or anything. What you see is the result of distortion due to perspective. So first of all you have to know what you are seeing is CORRECT.

    Now if you want your game (or whatever you are doing) to be different you have to specify what is your desired objective. You want to have a 3D Scene but see it in 2D ? Then you have to use an Orthographic Camera. However using this you will lose the depth of your scene so you will not be able to differentiate what is far of what is close.

    Now in 3D you only have 2 type of projection. The first, orthographic and the second perspective. Perspective is what mimic best what we see in real life and thus is what is used in every game out there to render a 3d scene.

    Now for what reason would you not want to use a perspective projection ?

    I have to understand exactly what you want to achieve so I can help you better. What is your end result ? If its to do a duck hunt in 3D then you already have something working without any "bug".

    It may APPEAR strange but the simulation is all good, you bullet is behaving normally. If you want to convince yourself spawn a bullet in the middle of the screen where you believe the behavior is correct. Now while the bullet is in the air, turn the camera so your bullet is shown in one corner of the screen (where you see a problem). Notice that the bullet appears to be going right or left now. This is only a distortion and a normal one.

    And has a side note, I noticed that your bullet Model is scaled to 0.5, this is not good for physic enabled objects, you should scale down your model in your modelling application and use a scale of 1.

    I hope this will help you out.
     
  7. myunity

    myunity

    Joined:
    Nov 7, 2009
    Posts:
    117
    very very thanks for nice answer dear friend.

    I got that bullet have right path and it is without problem in fact,and it is a distortion due to perspective.but i want don't have this distrotion.i want to it be more Real.i saw it before in another engine and it has not any problem!

    End result:

    i want to create a bullet in a x,y pixel coordinate and then shoot it Straightforward with gravity.gravity can be a fake gravity.means that we can use gravity in code and disable unity's Use Gravity.
     
  8. FrimaMickD

    FrimaMickD

    Joined:
    Jan 4, 2010
    Posts:
    7
    Using fake gravity will not help in any way. Honestly I doubt any other engine will have a different result, I might try with some others I have worked with but like I said I'm pretty confident this will do the exact same behavior.

    Changing for a smaller FOV might help a little. Try with 30, maybe the distortion will be less apparent.

    You can also take a look at this :

    http://en.wikipedia.org/wiki/Perspective_correction

    Good luck to you.
     
  9. Overunity3d

    Overunity3d

    Joined:
    Sep 5, 2010
    Posts:
    14
    I instantiate a prefab using a spawnpoint. This spawnpoint is at the bottom of a gameobject hierarchy.
    The instantiated prefab does not spin with the world.
    I see that the instantiated prefabs are sitting outside of game hierarchy as singularities. So of course the prefabs don't spin. Do I need a var of some type of vector3 or Quaternion parameter?
    OR
    how do I instantiate a prefab in at the same level as the spawnpoint or do I need to?

    Here is code:
    var cloneshot = Instantiate(Pulsarshoot, GameObject.Find("SpawnPoint").transform.position, transform.rotation);
    cloneshot.rigidbody.AddForce(transform.forward * 50000);

    Thanks in advance! :?: