Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

jediaction

Peek Script

Recommended Posts

To Anyone who still wants this work with the fpskit, I have removed variables being in the update function causing errors Also allowed two camera's for MainCamera, WeaponCamera so both move and the muzzleflash/raycast works.

 

Please login or register to see this spoiler.

 

Your welcome, "Cheer" for grave digging :)

 

edit: to fix being able to peek through walls lol... Add a sphere collider to the maincamera and change its radius to 0.2 and apply to ice physic material ;)

EDIT: Having a sphere collider stops you driving the buggy LOL! so... yeah :) just a heads up :)

Edited by Epic-Shot

Share this post


Link to post
Share on other sites

this script does not work in C#

 

using UnityEngine;
using System.Collections;
 
public class Peek : MonoBehaviour {
 
 
 
 
 
 
public Transform cam;
private float nextPos;
private float nextPos2;
private float dampVelocity;
private float dampVelocity2;
 
void Update (){
   float newPos= Mathf.SmoothDamp(cam.position.x, nextPos, ref dampVelocity, 0.2f);
    float newPos2= Mathf.SmoothDamp(cam.position.y,  nextPos2, ref dampVelocity2, 0.2f);
 
  float pos = cam.position.x;
       
       pos = newPos;
    float pos2 = cam.position.y;
   pos2 = newPos2;
 
   if (Input.GetKey("e"))
   {
       
        nextPos = 0.7f;
        nextPos2 = 1;
    }else if(Input.GetKey("t")){
        nextPos = -0.7f;
        nextPos2 = 1;
    }else if(Input.GetKey("c")){  
        nextPos = 0.0f;
        nextPos2 = 1f;
    }else{
        nextPos = 0.0f;
        nextPos2 = 1;
    }
}
 
}

Share this post


Link to post
Share on other sites

Great work on your simple peek script. A few tips for your programming skills:

- Start using else if(statement) instead of else{ if(statement) because it leads to cleaner code and efficient processing.

- When key binding for controls always use Input.GetAxis("Horizontal") instead of Input.GetKey("a") and then again for the opposite letter because GetAxis() returns not only a boolean but a float from from -1.0 to 1.0. This is useful and more efficient because you can transform this:

Please login or register to see this code. To a more efficient and smart way: Please login or register to see this code. GetAxisRaw is used for acquiring a non interpolated value so prevent double interpolation when using Mathf.SmoothDamp to suit your code.

GetAxis also prevents weird actions when pressing both keys at the same time, so it prevents any glitches happening whilst controlling in your game.

Great job on your peak script. Hope you take my advice and have fun developing :)

Share this post


Link to post
Share on other sites

Remove the variables that are at the beginning of the update function. Those shouldn't be there

Share this post


Link to post
Share on other sites

Hi i know this is a very old topic lol

but i was using this script in my project and it  worked great.. btw now i upgraded t ounty 2018.3 andmaybe since jc is deprecated script doesnt work anymore..

 

so please could someone try to coventer it to c# i tried but i'm not so able to make that... 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...