A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: 3D Game

  1. #1
    Senior Member SpikeyOmega's Avatar
    Join Date
    Dec 2004
    Posts
    400

    3D Game

    Hello, I am making a game where you can walk in a 3D room. However, it uses hitTest and Flash won't care what you (Z) position is. How can you set the Z Position? (Not Depth, depth is just layering)

  2. #2
    Opu Nui
    Join Date
    Jan 2003
    Location
    I'd rather be in Hawaii
    Posts
    79
    In your 3D room, everything should have a scale value associated with it. The smaller the scale the farther away in front of your character that object would be.

    Therefore, if the vertical and horizontal scale values are roughly equal to 1 and the hitTest is true, your charater should be standing on top of the object.

  3. #3
    Senior Member SpikeyOmega's Avatar
    Join Date
    Dec 2004
    Posts
    400
    How do you set scales?

  4. #4
    Opu Nui
    Join Date
    Jan 2003
    Location
    I'd rather be in Hawaii
    Posts
    79
    MC._xscale, MC._yscale

    I was mistaken before, an object that is at original size will have a value of 100, not 1.

  5. #5
    Senior Member SpikeyOmega's Avatar
    Join Date
    Dec 2004
    Posts
    400
    Umm, xscale and yscale just change it's size, not its 3rd dimension position. Say your in the front of the room. If you jumped (and a button was in the back) it would register it as a hitTest because it looks like they hit, even though we no they are nowhere near eachother in reality.

  6. #6
    skylogic.ca MD004's Avatar
    Join Date
    Oct 2003
    Location
    Canada
    Posts
    366
    You could give each object a depth value, and it either tests for hitTests if you and the object are on the same depth, or it tests for hitTests then tests to see if you and the object are on the same depth.

    For example:
    Code:
    //(im calling it depth, but it can be anything you want, such as 'z' - it doesnt matter what you call it)
    if (object1.depth==character.depth) {
        if (object1.hitTest(character)) {
            //Whatever it does here
        }
    }
    And of course there's a lot more optimized ways of doing this, but i do believe this is the general idea.

    ~MD

  7. #7
    Senior Member SpikeyOmega's Avatar
    Join Date
    Dec 2004
    Posts
    400
    Lol thanks, and then as the character is walking up it just subtracts depth?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center