Jump to content
  • Advertisement

Recommended Posts

I need help on a script. I am recreating a scene from A Hat In Time where Hat Girl goes into Queen Vanessa's manor. She has to collect keys and avoid Queen Vanessa. How would I script the door where you can open it and peek through it without actually going out the door? Any help is appreciated. Thanks!

EDIT: Not peeking throught the keyhole, just poke your head out the door

Share this post


Link to post
Share on other sites
Advertisement

Are you modding the game or recreating something using an existing engine that you're not totally familiar with yet?  We'll need to know what exactly you're dealing with to offer more detailed suggestions.

Edited by Nypyren

Share this post


Link to post
Share on other sites
2 minutes ago, Nypyren said:

Are you modding the game or recreating something using an existing engine that you're not totally familiar with yet?  We'll need to know what exactly you're dealing with to offer more detailed suggestions.

I am recreating a set of actions from Unreal Engine to Unity 

Share this post


Link to post
Share on other sites

Normally with a door, you'll either move the collider with the moving part of the door, or just disable the collider at a specific point.  You can use an animation to open the door or use physics and apply force or torque to open it.

With the door that you only want the user to peek through, you'll probably want to use an animation to control the door.  Don't do anything with the collider; just move the rendered mesh so that you can actually see through/around it.  Put the player into a state where they can only perform actions you want them to, or cancel peeking.

I can't quite tell from your posts, but just in case you haven't done any scripting in Unity yet, it would be best to start by reading/watching all of the online tutorials that are available first.

Share this post


Link to post
Share on other sites
2 hours ago, Nypyren said:

Normally with a door, you'll either move the collider with the moving part of the door, or just disable the collider at a specific point.  You can use an animation to open the door or use physics and apply force or torque to open it.

With the door that you only want the user to peek through, you'll probably want to use an animation to control the door.  Don't do anything with the collider; just move the rendered mesh so that you can actually see through/around it.  Put the player into a state where they can only perform actions you want them to, or cancel peeking.

I can't quite tell from your posts, but just in case you haven't done any scripting in Unity yet, it would be best to start by reading/watching all of the online tutorials that are available first.

I have scripted before

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
  • Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By bojanzarnoski@gmx.de
      Hello,
      I want to get into coding again by programming a 2D platformer to get started, but i don't know if i should use Java or C# with the unity engine.
      I am pretty fit with Java, but with c# i have to start from scratch. What do you recommend and why?
    • By SickTwistGames
      Ok, firstly, Hi.
       
      This is my first post on this forum. I am an Indie Dev making my first game so bear with me when I say dumb stuff, I'm on a huge learning curve.
       
      My first question is about inventory systems for unity. I am trying to make a survival type game with crafting. I have purchased Inventory manager pro by devdog from the unity asset store and it seems like a pretty powerful assett but for an intermediate coder its a little tough to use.  I'm beginning to wonder if it was the right purchase.
      So my question is.... does anyone have any experience of inventory plugins / systems for unity and can anyone reccomend a system to me?
      It needs to have the following: Loot system, crafting system, character sheet, blueprint system,  character stats system. Ideally with as little coding as possible.
       
      Thanks
    • By ethancodes
      I've got a bug with my brick breaker style game. The bricks move down one line at a time ever 1.5 seconds. What appears to be happening is occasionally the ball will be just about to hit the brick when the brick moves down a line, and now the ball is behind it. I'm not sure how to fix this. I have two ideas but I'm not sure of implementation. 1 solution would be to check where they were and where they are going to be before rendering the frame. Then if they crossed paths, then register the brick as hit. Solution 2 would be change how the bricks move. I could maybe slide them down line by line, instead of a jump down. I'm not sure of this will fix the issue or not. Any ideas?
    • By Scouting Ninja
      Once again Unity is frustrating me to the point of insanity.
      What I am looking for is a way to find a ray intersect with the edges of the mesh, using Unity's already made collision system. I want to point out that I know how to do a line intersect, what I want to know is if Unity supports this already.

      The image above shows how I sweep a ray,intersecting the mesh. The top green image shows what I want and the red shows what Unity is giving me.
      I want to know if there is some way, to find the edges in Unity without creating a custom line intersection tool.
      Most engines I know don't use rays for this but instead use a plane like this:

      I checked the Unity "Plane intersection" but it is just a ray cast. It will still need me to find the vertices on the collision mesh to cast the ray from; if I am doing that then making my own line intersection tool is better.
       
      I looked online and can find anything on this. Also I don't want to cut the mesh, so I don't need a way to know what side is what.
      Does Unity even have collisions that support edge only detection?
    • By JuliaAxt
      Please help me with this code, this error is currently stopping my project 
      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      [RequireComponent(typeof(Rigidbody2D))]
      public class TapController : MonoBehaviour {
          public float tapForence = 10;
          public float tiltSmooth = 5;
          public Vector3 startPos;
          Rigidbody2D Rigidbody;
          Quaternion downRotation;
          Quaternion forwardRotation;
          private void Start() {
              Rigidbody = GetComponent<Rigidbody2D>();
              downRotation = Quaternion.Euler(0, 0, -90);
              forwardRotation = Quaternion.Euler(0, 0, 35);
        
          }
          private void Update() {
              if (Input.GetMouseButtonDown(0))
              {
                  transform.rotation = forwardRotation;
                  Rigidbody.AddForce(Vector2.up * tapForce, ForceMode2D.Force);   (The name `tapForce`does not exist in current context)
              }
              transform.rotation = Quaternion.Lerp(transform.rotation, downRotation, tiltSmooth * Time.deltaTime);
          }
      }
          void OnTriggerEnter2D(Collider2D col){
          if (col.gameObject.tag == "scoreZone")
          {
              // register a score event
              // play a sound
          }
          if (col.gameObject.tag == "deadZone")
          {
              Rigidbody.simulated = false;   (`Rigidbody` does not contain a definition for `simulated´) 
              //register a dead event
              //play a sound
          }
           }

      }
       
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!