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.

OcularCash

ADG
  • Content count

    3,701
  • Joined

  • Last visited

  • Days Won

    110

Everything posted by OcularCash

  1. @ErarnitoxCOD uses the same techniques I stated (hence the no wall clipping by using multi cameras). In fact, outside of shadows, the weapon and weapon camera don't even have to be a child of the player at all or even be anywhere near it. But yes, you can use the method you described but in the end, your going to have to add that 2nd camera to fix clipping anyways
  2. for one, you don't have a weapon camera, only a camera that is rendering everything including the weapon. You need to have a camera that only renders the weapon and a camera that renders everything else. Animating the main camera will not affect the weapon bc the weapon is a child of the weapon camera, not the main camera
  3. AI and sight

    @swipe2000problem with spherecasting is 2 things, distance and scale. Distance being that if something is currently inside the unit sphere, it will not pick it up. For instance, casting a 1 unit sphere forward 10 units, it will not pick up something that is at 0.5, 0.5, 0.5 because it's inside the casting sphere. and scale is just that, casting a 1 unit sphere 20 units will not pick up an object that is clearly visible at 0, 2, 10 because your not using a frustum, instead you are basically holding a long pill saying if you touch it I can see you. thats why it's always best to use view frustums (box or sphere "angle") bc costs less for the CPU and it gives more of a realistic viewing frame
  4. *New weapon wheel. Place on any object in the scene and the variables: class Weapon { var Name : String = ""; var icon : Texture2D; var object : GameObject; //var drawWeaponAnim : Animation; } public var weapons : Weapon[]; public var buttonSize : Vector2 = Vector2(50, 50); public var spread : float = 100; public var iconStyle : GUIStyle; private var selectedWeapon : int; private var guiSettingsApplied : boolean; private var fxClamp : float; private var curFXFloat : float; private var buttonRect : Rect; function Start() { for(var i = 0; i < weapons.Length; i++) { if(i != selectedWeapon) weapons[i].object.SetActive(false); else weapons[i].object.SetActive(true); } } function Update() { if(Input.GetKeyDown("`")) { if(fxClamp == 0) fxClamp = 1; else fxClamp = 0; } if(curFXFloat != fxClamp) curFXFloat = Mathf.MoveTowards(curFXFloat, fxClamp, Time.deltaTime * 5); } function OnGUI() { if(curFXFloat != 0.0) { GUI.color.a = curFXFloat; var fxOffset = spread * (1.0 + (1.0 - curFXFloat)); for(var i : float = 0; i < weapons.Length; i++) { var progression = i / weapons.Length; var angle = progression * Mathf.PI * 2 + curFXFloat; buttonRect = Rect(Screen.width/2.0 + (Mathf.Sin(angle) * fxOffset) - (buttonSize.x/2.0), Screen.height/2 + (Mathf.Cos(angle) * fxOffset) - (buttonSize.y/2.0), buttonSize.x, buttonSize.y); if(buttonRect.Contains(Event.current.mousePosition)) { buttonRect.width *= 1.2; buttonRect.height *= 1.2; buttonRect.x -= (buttonRect.width - buttonSize.x) / 2.0; buttonRect.y -= (buttonRect.height - buttonSize.y) / 2.0; } if(weapons[i].icon) { iconStyle.normal.background = weapons[i].icon; if(GUI.Button(buttonRect, "", iconStyle)) { SwapWeapons(i); } } else { iconStyle.normal.background = null; if(GUI.Button(buttonRect, weapons[i].Name, iconStyle)) { SwapWeapons(i); } } } if(weapons[selectedWeapon].icon) GUI.DrawTexture(Rect(Screen.width/2 - (buttonSize.x/2.0), Screen.height/2 - (buttonSize.y/2.0), buttonSize.x, buttonSize.y), weapons[selectedWeapon].icon); else GUI.Label(Rect(Screen.width/2 - (buttonSize.x/2.0), Screen.height/2 - (buttonSize.y/2.0), buttonSize.x, buttonSize.y), weapons[selectedWeapon].Name); } } function SwapWeapons(to : int) { weapons[selectedWeapon].object.SetActive(false); weapons[to].object.SetActive(true); selectedWeapon = to; //Play weapons[to].animation on your animation component. Make sure you uncomment it in the class above }
  5. Weapon Wheel (GUI Weapon Selection) *Update*

    Topic updated with the newest version
  6. Help To move Forward of the player direction

    It's no problem. Just remember, if you ever want to transform a vector into local space, whether it's a point in space, direction or rotation, refer to the transform methods and you will find them there
  7. Help To move Forward of the player direction

    No, in your first script. Change TempRigidbody.velocity = movementDir to TempRigidbody.velocity = transform.TransformDirection(movementDir);
  8. Help To move Forward of the player direction

    transform.TransformDirection(direction);
  9. Weapon Wheel (GUI Weapon Selection) *Update*

    I'll have to find it later if I even still have it. It used to be in this topic but when the forum was hacked awhile back, that's one of the things that was lost
  10. Need help making Runescape's Combat system (C#)

    In js I would do: function Update() { if(!attacking) Attack(target); } function Attack(target : Enemy) { attacking = true; while(target.health > 0) { Attack(); while(animation.IsPlaying(attackAnim)) { yield; } attacking = false; } which basically the exactly same thing just yields until the attack animation is finished instead of time.
  11. Weapon Wheel (GUI Weapon Selection) *Update*

    The problem with this is that it's old so it uses the old GUI system (higher draw count). But all you do is drop it on a scene object and fill in the variables
  12. Weapon Wheel (GUI Weapon Selection) *Update*

    @kshitiz621never left. What's up?
  13. Shoot ray from the object's next frame position?

    In a blank scene, yes you can make your own controller like that but your going to have some severe issues once you have a full scene and simple raycasts are no longer gonna cut it. That's why I mentioned character controller and rigidbodies bc in order to make your own, your going to have to build an entirely new physics response library, not just a raycast
  14. Read/Write From .txt file

    Here is the save load script I wrote for Delirious Devon. This is not meant to be dragged into your project, it's just for you to see how it's done, that's it. public var sceneData : SceneData[]; public var currentPath : String; class SceneData { var coins : String = ""; var bruteberries : String = ""; var cloakanuts : String = ""; var chests : String = ""; var costumes : String = ""; } public var coins : int; private var health : float = 100; private var invisibility : float = 100; private var sceneCount : int = 2; private var t : int; function NewGame() { coins = 0; health = 100.0; invisibility = 100.0; sceneData = new SceneData[sceneCount]; for(var i = 0; i < sceneCount; i++) sceneData[i] = new SceneData(); currentPath = Application.dataPath + "/Saves/GameSave.txt"; SaveGame(); } function LoadGame(path : String) { currentPath = path; sceneData = new SceneData[sceneCount]; var line : String; var sr : StreamReader = new StreamReader(currentPath); line = sr.ReadLine(); if(line != null) { coins = parseInt(line.Split(" "[0])[1]); health = parseFloat(sr.ReadLine().Split(" "[0])[1]); if(health > 100.0) health = 100.0; invisibility = parseFloat(sr.ReadLine().Split(" "[0])[1]); if(invisibility > 100.0) invisibility = 100.0; line = sr.ReadLine(); var currentScene : int = 0; while(line != null) { sceneData[currentScene] = new SceneData(); var splitLine : String[]; splitLine = sr.ReadLine().Split(" "[0]); if(splitLine.Length > 1) { sceneData[currentScene].coins = splitLine[1]; } splitLine = sr.ReadLine().Split(" "[0]); if(splitLine.Length > 1) { sceneData[currentScene].bruteberries = splitLine[1]; } splitLine = sr.ReadLine().Split(" "[0]); if(splitLine.Length > 1) { sceneData[currentScene].cloakanuts = splitLine[1]; } splitLine = sr.ReadLine().Split(" "[0]); if(splitLine.Length > 1) { sceneData[currentScene].chests = splitLine[1]; } splitLine = sr.ReadLine().Split(" "[0]); if(splitLine.Length > 1) { sceneData[currentScene].costumes = splitLine[1]; } line = sr.ReadLine(); currentScene++; } } sr.Close(); } function SaveGame(index : String) { var sr = File.CreateText(currentPath); sr.WriteLine("Coins: " + coins.ToString()); sr.WriteLine("Health: " + health.ToString()); sr.WriteLine("Invisibility: " + invisibility.ToString()); for(var i = 0; i < sceneData.Length; i++) { sr.WriteLine(""); sr.WriteLine("CoinObjects: " + sceneData[i].coins); sr.WriteLine("BruteberryObjects: " + sceneData[i].bruteberries); sr.WriteLine("CloakanutObjects: " + sceneData[i].cloakanuts); sr.WriteLine("ChestObjects: " + sceneData[i].chests); sr.WriteLine("Costumes: " + sceneData[i].costumes); } sr.Close(); } function SaveGame() { var sr = File.CreateText(currentPath); sr.WriteLine("Coins: " + coins.ToString()); sr.WriteLine("Health: " + health.ToString()); sr.WriteLine("Invisibility: " + invisibility.ToString()); for(var i = 0; i < sceneData.Length; i++) { sceneData[i] = new SceneData(); sr.WriteLine(""); sr.WriteLine("CoinObjects: " + sceneData[i].coins); sr.WriteLine("BruteberryObjects: " + sceneData[i].bruteberries); sr.WriteLine("CloakanutObjects: " + sceneData[i].cloakanuts); sr.WriteLine("ChestObjects: " + sceneData[i].chests); sr.WriteLine("Costumes:" + sceneData[i].costumes); } sr.Close(); } function GetStats(){return [coins, health, invisibility];} function SetStats(stats : float[]) { coins = stats[0]; health = stats[1]; invisibility = stats[2]; } Scenedata strings are just lists of 0's and 1's that are represented as booleans. 1 representing has not been picked up in the scene, 0 representing that it has been. And this is what the save file looks like: Coins: 0 Health: 100 Invisibility: 100 CoinObjects: 1111111111111111111111111111111111111111111111111 BruteberryObjects: 1111 CloakanutObjects: 1111111111111111 ChestObjects: Costumes: 1111 CoinObjects: BruteberryObjects: CloakanutObjects: ChestObjects: Costumes:
  15. How to convert .max files into .fbx ?

    Before ppl start posting like crazy to this topic, it's almost 3 years old, I'm sure he's gotten it working since then
  16. Shoot ray from the object's next frame position?

    If you are using a character controller, transform.position "IS" the next position after you call controller.move. So you can literally say: //save your position var pos = transform.position; //move the controller to the next position controller.Move(controller.velocity); var nextPosition = transform.position; //reset the transforms position transform.position = pos; as for a rigidbody controller tho, there is no way you can predict where the character is going to be until the next frame because it has to wait for the physics loop. Character controllers have immediate physics that allows physics to be done on the fly.
  17. Climbing

    Yours works fine, but clicking on his says "Access is not available for your account". edit: thinking about it, it may be bc I'm clicking on it on my phone and maybe iPhone can't download/view an MP4
  18. Climbing

    I tried clicking on your link and sent me to a restricted access page.. which is kinda weird because I'm a team member, I have no restricted access. So I take it your having a relativity issue. The problem with a climbing animation to actually climb instead of animate is just that, it moves the mesh instead of the controller. in normal circumstances you would code the controller to move and make the climbing animation not move its hips (so the character doesn't move up and over, it stays where it's at and the controller moves it by code). The only way I could possibly think of to use 99% strictly animation is to animate the mesh, then after the animation, say transform.position = hips.position - (Vector3.down * offset) but finding the perfect offset would be a pain. If you want, take a look at the parkour example project I have in the downloads section. It plays the animation in one spot and moves the controller to where it needs to be. It's in js but should be pretty easy to understand
  19. Grass by blender for unity ?

    If your using unity terrain, just import it to the terrain and adjust the settings. If not, you'll need a shader that does it for you. All the shader has to do is move the vertices based on height from the lowest vertices. As for a shader like that, your probably on your own making it
  20. 2D Glitchy Movement

    And I know it's already answered and way overkill. But instead of rotating, you can also just say: if(horizontal != 0) transform.localScale.x = horizontal; and thats it. -1 in scale actually flips it for you. Just FYI for the future
  21. AI and sight

    My own approach is to check if the player is within a viewing angle. If it is, then linecast to the players head from the ai's head and see if it hits something (besides the player), is so, it can't see it, else it can. You can also raycast to the center + all 8 corners of the render bounds, but this can be taxing when there's tons of ai. The more realistic you want it, the more processing power it will need. If you stick with checking if the enemies head is in sight of the players head, it should be just fine without intense processing
  22. 2D Glitchy Movement

    How about we simplify it and just say: public Animator anim; public Quaternion turn; private bool wasDown = false; void Update() { float horizontal = Input.GetAxisRaw("Horizontal"); if(horizontal != 0) { turn.y = 90 + (horizontal * 90); transform.rotation = turn; if(!wasDown) anim.SetBool(isForwardDown", true); wasDown = true; } else { if(wasDown) anim.SetBool("isForwardDown", false); wasDown = false; } } ideally, you would actually want to animate based on velocity and grounded instead of input but the example above is based on the code you posted. The reason is that if you hit a wall and are no longer actually moving, your animator would still think it should animate. Using velocity fixes that issue
  23. Character Controller Broken

    Then I would say something is wrong with the coding and/or input. Works just fine for me in u5.6. Like I said before, I don't think it's a char controller issue, I think something else is doing it
  24. Weapon Clipping

    There's really no tutorial needed, it's very basic stuff. The basic idea is: if(Physics.Raycast(transform.forward,hit, 1)) { animation.CrossFade("LiftGun"); } else animation.CrossFade("LowerGun"); that's pretty much it. https://docs.unity3d.com/ScriptReference/Physics.Raycast.html https://docs.unity3d.com/ScriptReference/Animation.html as a beginner, just scroll the docs and take notes. Everything is there
  25. Weapon Clipping

    Add a camera, set it's render priority to 1 and create a layer called weapon. Then make that camera only render the weapon layer and set its culling to depth. That makes it so it doesn't clip walls (on your camera). Next, you can either raycast or use a trigger cube. If the raycast or trigger cube hits something (that's not the players collider), then make the arms rotate towards transform.up, else, rotate towards transform.forward edit: scratch that. Just crossfade an animation instead of screwing with coding, it'll be a lot easier for you to make it look good. But you still wanna do the camera thing
×