Post news RSS Riddle-Element: Electro Rotator

“Into the Belly of the Beast” is a 3D action-adventure game with a two-dimensional playing field where you jump into the role of Sploosh, a seaworm who is heading out to bring back his swallowed children out of the belly of a gigantic waterbeast. On your journey through the diverse and unique locations of its guts, you make use of the given properties of this special environment to solve physic- and bodyelement puzzles. Master fights against DNA based enemies in creative and inventive ways.

Posted by on

Hello there,

in our third update 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.

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 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         initialZPositi

void FixedUpdate(){

        /// Determine Fwd direction
        Vector3 fwd = transform.TransformDirection(Vector3.forward);

        /// Fire Raycast => Fwd with MaxDistance
        if (Physics.Raycast(transform.position, fwd, maxDistance)){

            RaycastHit hit;
            float distanceToObject = 0;
                if (Physics.Raycast(transform.position, fwd, out hit)){
                /// New Distance because => is in maxDistance and there is a hit
                distanceToObject = hit.distance-distanceToObjectOffset;
                /// Reset of Main_Particle_size
                /// Repositioning of subParticle and enabled the emission
                subParticle.transform.localPosition=new Vector3(subParticle.transform.localPosition.x,subParticle.transform.localPosition.y,((distanceToObject*initialZPositionOfSubParticle)/factorLaser));

                /// If is LifeForm => Damage it!!!!
                LifeForm lifeForm;
                lifeForm = LifeForm.GetLifeFormFromTransform(hit.transform);

            /// If is nothing in range here set mainParticle to max and dont emit sub_Particle

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

Hope you guys like it, thanks for reading!

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.