GameObject collision with screen
Hello everyone,
I was wondering, in C#, is it possible to check if a gameobject is touching the screen? At a certain point in my game, I would like to keep certain GameObject inside the screen. When you're screen moves to the right for example, the object stands still until the left side of the screen "touches" the object. Then the left side of the screen pushes the object to the right.
Is this possible and how do i do that?
Thank you :)
Hi,
Yes this is possible , but I didn't know this in too detail but there are few ways which I'm aware of like :- OnBecameInvisible (), fristum, you can also use this type of code :-
Vector2 stagePos = Camera.main.WorldToScreenPoint (transform.position);
if (stagePos.y > Screen.height || stagePos.y < 0f) {
// Do your work here
}
Your answer
Follow this Question
Related Questions
Collision detection in 2017 3d 4.2f2 0 Answers
Check if a large number of gameobjects are colliding 1 Answer
Set properties to a group of objects 2 Answers
How do I get a parent gameobject for a MashFilter? 1 Answer
CountDown List Prefabs 0 Answers