Riddle-Element: Electro Rotator

Hello there,


in our third devblog we want to present you one of our puzzle elements and most important one of the problems we had while coding it and it’s solution.

New Puzzle-Element: Electro-Rotator

The Electro-Rotator was created to bring a new dynamic obstacle to the game. It moves in a clockwise direction making it more difficult for the player to pass this section.

When we first implemented the Electro-Rotator, it didn’t collide with the walls the way we wanted it nor adjust it's length dynamically. A collision with life forms didn’t stop the beam from passing through them.



The Solution: „RayCast“

A „RayCast“ involves intersecting a ray with the objects in an environment. In other words, a ray cast tells you what objects in the environment the ray runs into, and may return additional information as well (for example such as the intersection point).

All values were set to the positions we already had defined and damage dealt to lifeforms was also included.

Spoiler (Click to toggle)

void Start () {
        //initial_setted speed
        electroAnim.speed = speed;
        ///box_collider will be set on a releative correct distance as setted
        rayCollider.size=new Vector3(rayCollider.size.x,rayCollider.size.y,maxDistance*10f);
        ///box_collider center will be setted to 
        rayCollider.center=new Vector3(0,0,rayCollider.size.z/2f);

        ///The MainParticle is setted by an factor 12.5f because of mesh and size of created particle may be different on other particles
        /// Maximum Radius is set

        /// Our sub-particle such as dust and electro is transformed to the end of the Main_Particle
        subParticle.transform.localPosition=new Vector3(subParticle.transform.localPosition.x,subParticle.transform.localPosition.y,((maxDistance*initialZPositionOfSubParticle)/factorLaser));
        /// for propotinal calculating

Spoiler (Click to toggle)


The result of using „RayCast“ was awesome. Everything works as planned before, we are happy! :)



We'll be back next week with some more awesome stuff to show you!



Add new comment