Keeping a unit within view.

Corleone

New Member
Reaction score
44
I'm currently working on a side-scroller map ( camera moves north all the time ) and I want my unit to stay within view. I made a region ( called Playable Area <gen> ) covering most of the panning camera's view and I make it move north all the time. Also made a arrow-key-movement system that makes sure you stay within the borders of the region. However, when my unit leaves the camera view at the bottom of the screen it doesn't keep it within the region borders, so I tried using
Code:
Keep in view
    Events
        Game - MyUnitY becomes Less than or equal to (Min Y of Playable Area <gen>)
    Conditions
    Actions
        Unit - Move MyUnit 0000 <gen> instantly to (MyUnitPosition offset by 100.00 towards (Facing of MyUnit 0000 <gen>) degrees), facing 90.00 degrees
        Set MyUnitPosition = (Position of MyUnit 0000 <gen>)
        Set MyUnitY = (Y of MyUnitPosition)
For some reason, it doesn't do anything though. Anyone got an idea what else I should try?
 

Corleone

New Member
Reaction score
44
Code:
        Game - MyUnitY becomes Less than or equal to (Min Y of Playable Area <gen>)
is maybe wrong? Try to debug your code.

Well, I tried lots of things for that, but I just can't seem to figure out what value would be right. If I could compare "MyUnitY" to another 'preset' real then that should work. However, thats not possible with this event. "MyUnitY" is being set every 0.20 seconds using another event, by the way, so that it's always 'up-to-date'. I dont know whether the (Min Y of Playable Area <gen>) is being updated or that it just sticks with the original value.
 

Chocobo

White-Flower
Reaction score
409
Well, I tried lots of things for that, but I just can't seem to figure out what value would be right. If I could compare "MyUnitY" to another 'preset' real then that should work. However, thats not possible with this event. "MyUnitY" is being set every 0.20 seconds using another event, by the way, so that it's always 'up-to-date'. I dont know whether the (Min Y of Playable Area <gen>) is being updated or that it just sticks with the original value.
MyUnitY = Pre-defined value. Can not be changed.
(Min Y of Playable Area <gen>) = Pre-defined value. Can't be changed.

You should use a periodic event.
 

Corleone

New Member
Reaction score
44
Strange.. I tried using similar periodic events to do this, but this time it works properly, for some reason.

Code:
Periodic Keep in view
    Events
        Time - Every 0.40 seconds of game time
    Conditions
        (Number of units in (Units in Playable Area <gen> owned by Player 1 (Red))) Equal to 0
    Actions
        Unit - Move MyUnit 0000 <gen> instantly to (MyUnitPosition offset by 150.00 towards 90.00 degrees)
        Set MyUnitPosition = (Position of MyUnit 0000 <gen>)
This very same trigger used to make my unit move north all the time, instead of only when its outside the region.

Thanks for the help, Chocobo.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • jonas jonas:
    Oh, I see. I thought Chinese version of A-levels :D
  • jonas jonas:
    I've been using the translate app a lot on my phone. take a photo, translate. take another photo, translate again :D
  • jonas jonas:
    it also has voice translation, my colleagues sometimes use that
  • jonas jonas:
    You came during the 0 covid policy right? How'd you get through quarantine? Did you have some help with the apps and green codes?
  • tom_mai78101 tom_mai78101:
    If you have any Chinese you need help with, let me know.
    +1
  • vypur85 vypur85:
    @jonas Those were the things I did too. Translate app and VPN are always the most important things to have to survive. Lol.
  • vypur85 vypur85:
    Yea I came last year. I was quarantined for about 30 days. Fml. The first day of my quarantine was the eve of Chinese new year last year. Fml again... Lol.
  • vypur85 vypur85:
    @tom_mai78101 IIRC you're from Taiwan right.
  • The Helper The Helper:
    I thought China had cracked down on having any foreign teachers?
  • vypur85 vypur85:
    Yeah I've heard of the news before. My school is still actively hiring foreign teachers. Not sure how things work now.
  • The Helper The Helper:
    yeah it is hard to get reliable information about that kind of stuff
  • The Helper The Helper:
    but you are doing it so it is still doable
  • vypur85 vypur85:
    I think it doesn't affect existing foreign teachers. Then again, its still weird that my school is hiring.
  • The Helper The Helper:
    Happy Monday people hope everyone has a fantastic week!
  • Ghan Ghan:
    Happy Monday?! That's a contradiction.
  • jonas jonas:
  • jonas jonas:
    please put this in the news section, it's crazy
  • tom_mai78101 tom_mai78101:
    Technically, you can post in the Headline News. Just posted your news there.
  • tom_mai78101 tom_mai78101:
    I'm not aware of you not being able to post news.
  • jonas jonas:
    I think technically I can I just forget how
    +1
  • The Helper The Helper:
    Happy Thursday!
  • The Helper The Helper:
    Happy Friday Night!
    +1
  • V-SNES V-SNES:
    Happy Friday night!
    +1
  • vypur85 vypur85:
    Happy Sunday. Sigh. Work day tomorrow.
    +1

    The Helper Discord

    Members online

    No members online now.

    Affiliates

    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.
    Top