1
votes

I'm working on a kind of break-out clone 3d thingy type game. This is what I have for my Arena so far:

enter image description here

The Arena is:

  • Arena
    • Walls: 6 Cubes. Mesh Colliders. Front wall is "transparent".
    • Balls: n Balls. Rigidbodies. Bounce around, breaking out of stuff
    • Paddle: A cube or a circular shaped item that deflects based on where it's hit (To be fleshed out)
    • Bricks: Square thingies that disappear when hit (To be fleshed out)

What I've found is that it's hard'ish to track the balls in 3d... vs a "simple" 2d version.

As the balls bounce around, I want them to create "shadows" on the "transparent" "Front" wall. I think that'll make it easier to match paddle to ball during a "real" game.

How would you attach a "shadow" (Grows bigger/darker as ball gets closer to "front") to a transparent wall? On either side?

Full Code at BitBucket, and the BallScript hidden therein.

1

1 Answers

0
votes

assuming x is left/right and y is up/down and z is close/far:

add an object (your shadow) for each ball on your front transparent wall and update its transform.position x and y with the x and y of the ball (keep z as it is)

to make it bigger / and or darker, use

Vector3.Distance( ball.transform.position, shadow.transform.position )

to calculate a factor. use this factor to set shadow.transform.scale and to change the color of the material of the shadow.